Printing a Range Of Records Using A Button

Joined
Sep 10, 2014
Messages
1
Reaction score
0
Hello,

I am fairly new to VBA so I apologize in advance for my lack of knowledge. I've created several buttons to perform various things such as autofilling tables and printing records with certain where conditions so I thought this would be a simple thing to figure out in comparison but that is clearly not the case.

What I am trying to do is print a range of records between two manually inputted values (alphanumeric) that exist in a form. What I've done is created a form with 2 fields (Start and End) along with a button. I want the button to print all records between (and including) the start and end fields using a specific report. I wanted to use a simple where condition but am struggling with finding the correct command and syntax to do so. Any help would be much appreciated. I was thinking to do it with the statement below:

DoCmd.OpenReport "Shipping - Labels (Rack)", , , "[first rack #]" >= " & Me.Rack & " And "[last rack #]" <= " & Me.Rack & "

first rack # = start, last rack #=end, "Rack" is the field in the report that contains the data I want to filter.

I don't get an error using this command, however, all I get is a blank page. Is my logic at least close or am I completely in left field?
 
Joined
Oct 3, 2014
Messages
16
Reaction score
1
Try this: DoCmd.OpenReport "Shipping - Labels (Rack)", , , "[first rack#]>=" & Me.Rack & " And " & "[last rack #] <= " & Me.Rack & ""
Note: at the end the are two double quotes (" ") - without the space.
This should do the trick for you ;-)
 

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