Print a report from a form with multiple IDs

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
 
G

Guest

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] & "#"
 
G

Guest

Date/Time fields need # as a delimiter:
try

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

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