Pick Record from certain record for a parameter query (1 Viewer)

June7

AWF VIP
Local time
Today, 03:35
Joined
Mar 9, 2014
Messages
5,423
Yes, I got it to work as described in post 13.

Since I don't see any problem with posted code, provide db for analysis. Follow instructions at bottom of my post.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 07:35
Joined
Feb 19, 2002
Messages
42,970
Add a coma following your existing OpenForm

DoCmd.OpenForm "FRMVehiclesInWorkshops",

The results are miraculous. Intellisense shows you all the other arguments for this method. You need to provide a value for the WHERE argument. That will make the form open to the record you are currently sitting on. AND PS for the person who asked, it is completely irrelevant whether you run this OpenForm command from a single or continuous form. Why? Because ONLY ONE record is ever current regardless of the form type and that is what you get when you refer to Me.somecontrolname.
 

stu_c

Registered User.
Local time
Today, 11:35
Joined
Sep 20, 2007
Messages
489
Hi All
After a lot of the headache I have worked out it was due to it being in a sub form within a form.

I have tried everything for it to work within that but no success, any suggestions on how to get round that as ideally could do with in within one.
 

June7

AWF VIP
Local time
Today, 03:35
Joined
Mar 9, 2014
Messages
5,423
The dynamic parameterized query will not work because the referenced form is now within a subform container which requires the referencing to be different. Either change the dynamic parameter to reference form through the subform container or eliminate the dynamic parameter in query and use VBA to set the WHERE argument of OpenForm command. I recommend the latter as stated back in post 13.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 07:35
Joined
Feb 19, 2002
Messages
42,970
You can't use the OpenForm method to pass criteria to the subform. You have to use a different method. I would use a RecordSource query for the subform and reference the "calling" form for criteria:

Where SomeField = Forms!myform!SomeField
 

June7

AWF VIP
Local time
Today, 03:35
Joined
Mar 9, 2014
Messages
5,423
I don't think the intent is to pass criteria TO subform, it is to reference field of subform to open another form.
 

Users who are viewing this thread

Top Bottom