Print a report from a form with multiple IDs

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

Guest

I have a form that has two primary keys: DateDraw and PhlebName.

I want to print the form to a report and am using the following code:

Private Sub Command10_Click()
Dim strWhere As String
If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If
If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strWhere = "[DrawDate] = " & Me.[DrawDate]
DoCmd.OpenReport "Print Current Report", acViewPreview, ,
strWhere
End If
End Sub

I keep getting a data mismatch error (DrawDate is a Date/Time datatype and
PhlebName is a text type). Could someone point me in the right direction??

Thanks
 
Hey Sean, any dates need to have the pound sign(#) in the front and back of
the date, e.g., #1-01-2005#. Try changing this line of code:

strWhere = "[DrawDate] = " & Me.[DrawDate]

to

strWhere = "[DrawDate] = #" & Me.[DrawDate] & "#"
 
Date/Time fields need # as a delimiter:
try

strWhere = "[DrawDate] = #" & Me.[DrawDate] & "#"
 
Back
Top