Open Form Using Variable

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
 
V

Van T. Dinh

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

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

Gary Pollard

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top