Command button to open report

J

Jim

I have a combo box that finds records on a subform, this is working fine. I
added a command button to preview a report of the same set of records and
can't get it to work - it opens the report with all records showing. I've
tried code posted in the newsgroups, missing something.

This is my latest attempt:
Dim strwhere As String
strwhere = "[Sector]= " & Me.[Combo4]
DoCmd.OpenReport "LECXREF", acViewPreview, , strwhere

Sector is the field on my report that matches Combo4 on the main form.
Thanks,
Jim
 
D

Daniel Pineault

Assuming Me.[Combo4] is a textual value, try:

Dim strwhere As String
strwhere = "[Sector]= '" & Me.[Combo4] & "'"
DoCmd.OpenReport "LECXREF", acViewPreview, , strwhere

--
Hope this helps,

Daniel Pineault
http://www.cardaconsultants.com/
For Access Tips and Examples: http://www.devhut.net
Please rate this post using the vote buttons if it was helpful.
 

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