Print Single Record from a form using "As Integer"

M

Matt

Because the criteria I want to use to print a single
record from a form is a number, I modified MS' code
example on printing a single record from a form (the
criteria used in the code example is text). My
modification is not producing the results I expected. I'm
getting a multipage report that includes every record.
The modified code I used is below. Any suggestions?

Dim strreportname As String
Dim strcriteria As Integer

strreportname = "rpt_PrintRecord"
strcriteria = [IRNum]
DoCmd.OpenReport strreportname, acViewPreview, ,
strcriteria

Thanks for any help.

Matt
 
F

fredg

Matt said:
Because the criteria I want to use to print a single
record from a form is a number, I modified MS' code
example on printing a single record from a form (the
criteria used in the code example is text). My
modification is not producing the results I expected. I'm
getting a multipage report that includes every record.
The modified code I used is below. Any suggestions?

Dim strreportname As String
Dim strcriteria As Integer

strreportname = "rpt_PrintRecord"
strcriteria = [IRNum]
DoCmd.OpenReport strreportname, acViewPreview, ,
strcriteria

Thanks for any help.

Matt
Matt,

Regardless of whether the prime key field's datatype is number, string,
date, etc., the Where clause MUST always be a string!!!

Dim strCriteria as String
strCriteria = "[IRNum] = " & Me![IRNum]

the above will become (if [IRNum] is number 25)
"[IRNum] = 25"

See Access Help files on:
Where Clause + Restrict data to a subset of records
to learn how to write the where clause using different datatypes.
 
M

Matt

Thanks much for the help, Fred! Happy Holidays!

-----Original Message-----
Matt said:
Because the criteria I want to use to print a single
record from a form is a number, I modified MS' code
example on printing a single record from a form (the
criteria used in the code example is text). My
modification is not producing the results I expected. I'm
getting a multipage report that includes every record.
The modified code I used is below. Any suggestions?

Dim strreportname As String
Dim strcriteria As Integer

strreportname = "rpt_PrintRecord"
strcriteria = [IRNum]
DoCmd.OpenReport strreportname, acViewPreview, ,
strcriteria

Thanks for any help.

Matt
Matt,

Regardless of whether the prime key field's datatype is number, string,
date, etc., the Where clause MUST always be a string!!!

Dim strCriteria as String
strCriteria = "[IRNum] = " & Me![IRNum]

the above will become (if [IRNum] is number 25)
"[IRNum] = 25"

See Access Help files on:
Where Clause + Restrict data to a subset of records
to learn how to write the where clause using different datatypes.


--
Fred
Please reply only to this newsgroup.
I do not respond to personal e-mail.
.
 

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