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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Where Condition in Docmd.OpenReport 1

Status
Not open for further replies.

BLBurden

Technical User
Jan 25, 2003
236
US
Hello all, I have an expression in a macro that works fine. But I was just wordering if is is possbile to convert it to VB. I am just trying to learn more about VB. I've check the Docmd help syntax and got the general ideal but could not get to it work as I wish.

My macro expression is: [CA/PA Champion]=[Forms]![Nonconformance]![CA/PA Champion]. This works great. It give me a parameter box which allows me to type whatever is in the control.

My VB code I tried to test is, DoCmd.OpenReport "champions", , ,"[ca/pa champion] = 'b.burden"and it works, if the only thing in this control was a single name, but it's not. Actualy this control is a combo box with several names and I want to be able to select from the list of names and open the report with the condition where they can select only their records.

Thanks guys for any help, suggestion or comments.



BLB[elephant2] - Always Grateful
A good friend will bail you out of jail. A true friend will be sitting at your side saying, "Boy - didn't we have fun?"
 
>My VB code I tried to test is, >DoCmd.OpenReport "champions", , ,"[ca/pa champion] >= 'b.burden"and it works, if the only thing in this >control was a single name, but it's not. Actualy this >control is a combo box with several names and I want to be >able to select from the list of names and open the report >with the condition where they can select only their >records.

Your 'where' clause in the docmd is not referring to any controls. The reference to [ca/pa champion] is a reference to the field in the recordsource for the report.

If you want the report to be based on the name selected in the combo box then you do something like:

DoCmd.OpenReport "champions", , ,"[ca/pa champion] = '" & me.comboname & "'"

where comboname is the name of your combobox on your form.
This assumes that the combobox is bound to the name field and not an id number (check the bound column property).


 
Thanks for your response lupins46, but I had already tried that one and it didn't work either. I think I will just stick to my expression builder, at least it works. Thanks again for your comment.

BLB[elephant2] - Always Grateful
A good friend will bail you out of jail. A true friend will be sitting at your side saying, "Boy - didn't we have fun?"
 
lupins46, I did manage to figure it out from your suggestion, and I have already given you a star. Thanks bunches.

BLB[elephant2] - Always Grateful
A good friend will bail you out of jail. A true friend will be sitting at your side saying, "Boy - didn't we have fun?"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top