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
LillyCDatabase DeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

John TsioumprisSoftware & Systems EngineerCommented:
I think something is missing....when you say "where condition"..what kind of linking you want...
In the form/subform scenario the subform is filtered according to the Parent form link field/s
LillyCDatabase DeveloperAuthor Commented:
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'?
John TsioumprisSoftware & Systems EngineerCommented:
can you give a screenshot...
The 7 Worst Nightmares of a Sysadmin

Fear not! To defend your business’ IT systems we’re going to shine a light on the seven most sinister terrors that haunt sysadmins. That way you can be sure there’s nothing in your stack waiting to go bump in the night.

LillyCDatabase DeveloperAuthor Commented:
Rey Obrero (Capricorn1)Commented:
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 & "'"


.
John TsioumprisSoftware & Systems EngineerCommented:
I think you need this
DoCmd.OpenForm "TheNameofForm", acNormal,,"ClientID = " & me.ClientID,,acDialog

Open in new window

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 & "'"

Open in new window

LillyCDatabase DeveloperAuthor Commented:
Is there any way I could do this within the macro rather than entering the code?
John TsioumprisSoftware & Systems EngineerCommented:
Your macro is failing probably because your criteria are alphanumeric...
you should have
Where Condition= [Client] = Chr(34) & [Forms]![YourForm]![ClientID] & Chr(34)
LillyCDatabase DeveloperAuthor Commented:
The client ID is a Autonumber, its not alphanumeric...
John TsioumprisSoftware & Systems EngineerCommented:
I think you need to read this
But the VBA code is easy ...you just put in the Click_event of the button you use

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
LillyCDatabase DeveloperAuthor Commented:
Thank you.
PatHartmanCommented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.