Open Form Using Variable

  • Thread starter Thread starter Gary Pollard
  • Start date Start date
G

Gary Pollard

Access 97

I would like to open a form using a command button and automatically feed
the query a variable.

The form uses the following SQL as its record source

SELECT DISTINCTROW [PrePress-1].Docket, [PrePress-1].*, [PrePress-2].*,
[PrePress-3].*
FROM ([PrePress-1] LEFT JOIN [PrePress-2] ON [PrePress-1].Docket =
[PrePress-2].Docket) LEFT JOIN [PrePress-3] ON [PrePress-2].Docket =
[PrePress-3].Docket
WHERE ((([PrePress-1].Docket)=[EnterDocketNumber]));

This works if I manually open the form and supply a value for
[EnterDocketNumber]

I have tried the following but get error - "[PrePress-1.Docket]" isn't a
valid parameter name
stDocName = "PrePress"
stLinkCriteria = "[PrePress-1.Docket]=" & Me![Docket]
DoCmd.OpenForm stDocName, , , stLinkCriteria


How do automate this?

Any Help Appreciated
 
Get rig of the WHERE clause in your Query and try:

stLinkCriteria = "[PrePress-1].[Docket]=" & Me![Docket]
 
That did it - thanks

Surprising what a pair of bracket will do
The line I was using -- (stLinkCriteria = "[PrePress-1.Docket]=" &
Me![Docket])
was generated by the command button wizard

Van T. Dinh said:
Get rig of the WHERE clause in your Query and try:

stLinkCriteria = "[PrePress-1].[Docket]=" & Me![Docket]


--
HTH
Van T. Dinh
MVP (Access)



Gary Pollard said:
Access 97

I would like to open a form using a command button and automatically feed
the query a variable.

The form uses the following SQL as its record source

SELECT DISTINCTROW [PrePress-1].Docket, [PrePress-1].*, [PrePress-2].*,
[PrePress-3].*
FROM ([PrePress-1] LEFT JOIN [PrePress-2] ON [PrePress-1].Docket =
[PrePress-2].Docket) LEFT JOIN [PrePress-3] ON [PrePress-2].Docket =
[PrePress-3].Docket
WHERE ((([PrePress-1].Docket)=[EnterDocketNumber]));

This works if I manually open the form and supply a value for
[EnterDocketNumber]

I have tried the following but get error - "[PrePress-1.Docket]" isn't a
valid parameter name
stDocName = "PrePress"
stLinkCriteria = "[PrePress-1.Docket]=" & Me![Docket]
DoCmd.OpenForm stDocName, , , stLinkCriteria


How do automate this?

Any Help Appreciated
 
Back
Top