Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hi, I have a form that will allow 1

Status
Not open for further replies.

rry2k

Programmer
Jun 28, 2001
678
US
Hi,
I have a form that will allow the user to select different options for different views in a report. I'm trying to use the where parameter in this doCmd statement. I took this out of a parm query that I wrote that does work outside the macro. When I run it from the form, I get an object not found.

Thanks for the help..Russ
Private Sub Option0_Click()
DoCmd.OpenReport "presentation", acViewPreview, , Presentation01.Candidate1 Like "*" & [Type a candidate:] & "*"

End Sub
 
Hi!

I think what you need is the following:

DoCmd.OpenReport "presentation", acViewPreview, ,
"Presentation01.Candidate1 Like '*" & InputBox(Type a candidate:) & "'*"

In the OpenReport method the whole where clause needs to be a string. If you want to allow the user to input information from code, use the InputBox function. I am assuming that Presentation01.Candidate1 is the field in the table. Finally, the code above assumes that Candidate1 is a text field.

hth
Jeff Bridgham
 
Hi again!

I made an error, Type a Candidate: in the InputBox function must be in quotes.

Sorry
Jeff Bridgham
 
Jeff,

Thanks it close. It got to the prompt box then when I entered it cried. I put in "" around the question then it gave me extra ) in statement I tried them off and in different places and it still grabs.
Thanks..R
 
Hi!

Post the code you tried and I'll see if I can see any problems.

Jeff Bridgham
 
Private Sub Option0_Click()
DoCmd.OpenReport "presentation", acViewPreview, , _
"Presentation01.Candidate1 Like '*" & InputBox("enter a candidate") & "'*" '

End Sub
 
Hi!

Well the only thing I see, and I don't know if it is just a typo in your post or not, is the last single quote. It shouldn't be there.

If that isn't the problem, then post the exact error message your are getting.

hth
Jeff Bridgham
 
I took out the ' ran it and received the following error
run-time error 3075
extra)in query expression '(presentation01.Candidate1 Like "*Weber"*)'
 
Hi!

I do see another error on my part. The last bit should be "*'" instead of "'*"

Jeff Bridgham
 
It's finally starting to work. Thanks for your help. I'm not getting syntax errors anymore just strange results. I'm getting like 4 prompt boxes. I think I need to possibly change the recordsource in the report it self to be blank and let the form do the work. If I can't get it I most post tommorrow with a closer solution. Thanks again for your time.. Russ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top