print a specific record

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to print the current record. This is the code I am using in the
on click event


Dim MyWhereCondition As String

MyWhereCondition = "RecordID= " & Me.InvestigationID
DoCmd.OpenReport "rpt_InvestigativeReport", acPreview, , MyWhereCondition

It functions, but will only printa specific record. I am using it on the
second form that is linked to the record ID field on the main form. The
report pulls information from both forms. What am I doing wrong? It prompts
me for the record ID and I type 18, but it gives me record 12.
 
The WhereCondition should be

MyWhereCondition = "[FieldNameInTheTable]= " & Me.[TextBoxNameInTheForm]

Is that what you did? because you mentioned that the "record ID field on the
main form"

If the field you are trying to filter on is text type field, you should add
a single column before and after the variable

MyWhereCondition = "[FieldNameInTheTable]= '" & Me.[TextBoxNameInTheForm] &
"'"
 

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

Back
Top