Parameter Value

K

kevtrucker

I have a form with 6 pages on it, the form also has various command buttons,
one of these command buttons i want to print a report based on the current
record showing on the front page of the form.
The following is the code i have for the print report button.

Private Sub Command351_Click()
Dim strReportName As String
Dim strCriteria As String

If NewRecord Then
MsgBox "This record contains no data." _
, vbInformation, "Invalid Action"
Exit Sub
Else
strReportName = "inspection sheet-p"
strCriteria = "[regnumber]=" & Me!regnumber

DoCmd.OpenReport strReportName, acViewPreview, , strCriteria

End If
End Sub

When i click on the button a message box appears asking for a parameter value,
the box also shows the value of the first field (regnumber) on the front page
of the form, when i enter the value into the box and press ok the report then
prints, i want this report to print automattically without the parameter
value box appearing.

The report is based on a simple query using 2 tables, one for vehicle details
and the other customer name and addresss, the main field that connects them
is vehicles.regnumber.

i have looked at other posts and can't find anything that covers my problem.

hopefully i have explained my problem clearly.

Thanks in advance for any assistance given.
Kevin
 
D

Duane Hookom

You didn't mention the data type of RegNumber. If it is text, you will need
to use:
strCriteria = "[regnumber]=""" & Me!regnumber & """ "
 
K

kevtrucker via AccessMonster.com

Duane

Thank you very much for your response, my apologies, yes it was a text field.

I tried your suggestion this morning and it worked perfectly, thank you very
much

I was looking for hours last night to find out how to stop the value box,
still i will know for the future.

Thanks again.

Kevin

Duane said:
You didn't mention the data type of RegNumber. If it is text, you will need
to use:
strCriteria = "[regnumber]=""" & Me!regnumber & """ "
I have a form with 6 pages on it, the form also has various command buttons,
one of these command buttons i want to print a report based on the current
[quoted text clipped - 34 lines]
Thanks in advance for any assistance given.
Kevin
 

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