LillyC
asked on
Linking ID's from form to form using the 'where condition'
Hello
Can anyone tell me how to link an ID from one form to another using the 'where condition' within a macro in Access 2013.
I've tried it several times but can't get it to work.
Thanks
Can anyone tell me how to link an ID from one form to another using the 'where condition' within a macro in Access 2013.
I've tried it several times but can't get it to work.
Thanks
ASKER
I'm not trying to link from a form to a subform.
Its a 'client details form' to a 'job details form' and I'm trying to get the Client ID to feed through, I thought this had to be done via the 'where condition'?
Its a 'client details form' to a 'job details form' and I'm trying to get the Client ID to feed through, I thought this had to be done via the 'where condition'?
can you give a screenshot...
ASKER
Hope this helps...
Screen-shot-for-Experts-Exchange.docx
Screen-shot-for-Experts-Exchange.docx
try this code
if clientid is Number type, use this
docmd.openform "formX",,, "[clientid]= " & me.clientId
if clientid is Text type, use this
docmd.openform "formX",,, "[clientid]= '" & me.clientId & "'"
.
if clientid is Number type, use this
docmd.openform "formX",,, "[clientid]= " & me.clientId
if clientid is Text type, use this
docmd.openform "formX",,, "[clientid]= '" & me.clientId & "'"
.
I think you need this
If your criteria are alphanumeric then you change this to
DoCmd.OpenForm "TheNameofForm", acNormal,,"ClientID = " & me.ClientID,,acDialog
Take a notice at the part "ClientID = " & me.ClientID which essentially is the WHERE condition but without the WHERE keyword...If your criteria are alphanumeric then you change this to
"ClientID = '" & me.ClientID & "'"
ASKER
Is there any way I could do this within the macro rather than entering the code?
Your macro is failing probably because your criteria are alphanumeric...
you should have
Where Condition= [Client] = Chr(34) & [Forms]![YourForm]![Client ID] & Chr(34)
you should have
Where Condition= [Client] = Chr(34) & [Forms]![YourForm]![Client
ASKER
The client ID is a Autonumber, its not alphanumeric...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you.
One thing the others left out is that if you add records with this popup form, you must populate the foreign key manually. With a subform, the master/child links take care of linking the two records. That isn't available in this case. So - using the popup form's BeforeInsert event -
Me.FK = Forms!originalform!PK
Me.FK = Forms!originalform!PK
In the form/subform scenario the subform is filtered according to the Parent form link field/s