Rabu, 24 April 2013

RE: [MS_AccessPros] Re: Autofill Linking info into a command button-opened child form

 

Heidi-

I'm wondering why you aren't simply using a subform to enter the game data.

If you want to use a separate form, you need to pass the GameID to the
second form using OpenArgs, like this:

DoCmd.OpenForm stDocName, WhereCondition:=stLinkCriteria,
OpenArgs:=Me.Game_ID

Then, in the Open event, grab the value and set the DefaultValue of Game_ID
like this:

If Len(Me.OpenArgs) > 0 Then
Me.Game_ID.DefaultValue = Me.OpenArgs
End If

That will ensure that every new record inherits the Game_ID created on the
main form.

John Viescas, Author
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications
SQL Queries for Mere Mortals
http://www.viescas.com/
(Paris, France)

------------------------
From: MS_Access_Professionals@yahoogroups.com
[mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of creaturenutt
Sent: Wednesday, April 24, 2013 9:04 PM
To: MS_Access_Professionals@yahoogroups.com
Subject: [MS_AccessPros] Re: Autofill Linking info into a command
button-opened child form

 
good afternoon -
I have what I believe is a simple coding question, but I'm not having much
luck on my own and hope someone can help:

I'm working in Access 2007, and I have a form where basic information is
added (FRM_GAMES). Each new record generates an autonumber primary key
(GAME_ID). The user then clicks a command button to open a related child
form (FRM_GAME_DATA) into which they will edit or add information. I would
like the GAME_ID lining field to be automatically filled in for each new
record. I believe I need to add a filter to the basic code in order to do
this. Can anyone tell me what I need to add and where?

stDocName = "SUBFRM_GAME_DATA"

stLinkCriteria = "[GAME_ID]=" & Me![GAME_ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Thank you in advance for any help you can provide.

__._,_.___
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (2)
Recent Activity:
MARKETPLACE


.

__,_._,___

Tidak ada komentar:

Posting Komentar