hard coding a parameter query

teiben

Registered User.
Local time
Today, 07:29
Joined
Jun 20, 2002
Messages
462
I have a report,which when run the user select their initial from a drop down box, which works great!
Now I have to automate the report(s) getting emailed each week. So I used the wizard and have a form w/command button which open the report. But it asks for the user initials. I want to hard code this so it doesn't prompt.

This is how the code reads:
Dim stDocName As String

stDocName = "rptInterimStatusByPerson"
DoCmd.SendObject acReport, stDocName

so I added
[Forms]![APQP]![UserId=BB], which doesn't work
[Forms]![APQP]![UserID] = "BB" , doesn't works

I've also tried various other code lines and it errors out.
HELP
 
If I'm understanding correctly, the report is based on a query and you need to have this criteria:
[Forms]![APQP]![UserID]
in your query. Is it?
 
Yes the report is based on a query.
 
Did you see the 2nd part of my post, about the criteria?
 
The report is based on a query. qInterimByPerson, [forms]![APQP]![userID] is the query. I'm trying to stop the parameter query from happening, via hard code. When I use the same line in my report, I get messages like can't find form APQP.
 
teiben

The form APQP needs to be open when you hit your command button otherwise you can't set the value of the field. If the form is not open then Access will return the error message you are currently seeing.

As long as the form is open your second suggestion should work, i.e.

[Forms]![APQP]![UserID] = "BB"

assuming that the control is a text type.
 
Problem is part two of the problem is, I have the command button opening a report, becuase the report needs to be emailed, to everyone (whose initials) are on the forms drop down list.

Any idea's on how to accomplish. I used the wizard, which under form is not an option.
 

Users who are viewing this thread

Back
Top Bottom