report based on combo box selection

R

rkg

I'm having trouble with printing a report. The report prints records
based on the name I select in a combo box and works great. I am trying
to get the same report to print base on a date selected in the combo
box. I've set the combo box to the date field called(entry_date) in
the query and changed the code to accept the date value instead of the
name but get errors each time.
Here is the code
Private Sub Combo7_AfterUpdate()
Dim strCriteria As String
strCriteria = "[entry_date] = """ &
Me.Combo7 & """"
If Not IsNull(DLookup("[entry_date]",
"qscale08", strCriteria)) Then
DoCmd.OpenReport "rscaletickets08",
WhereCondition:=strCriteria
Else
MsgBox "Name not found", vbInformation,
"Warning"
End If
End Sub
There seems to be some sort of data type mismatch. I know it's
something simple but just can't seem to get it. Could it be because
of the strCriteria As String?
Any help would be appreciated.

Thanks,
rkg
 
P

pietlinden

I'm having trouble with printing a report. The report prints records
based on the name I select in a combo box and works great. I am trying
to get the same report to print base on a date selected in the combo
box. I've set the combo box to the date field called(entry_date)  in
the query and changed the code to accept the date value instead of the
name but get errors each time.
Here is the code
                        Private Sub Combo7_AfterUpdate()
                            Dim strCriteria As String
                                 strCriteria = "[entry_date] = """ &
Me.Combo7 & """"
                                 If NotIsNull(DLookup("[entry_date]",
"qscale08", strCriteria)) Then
                            DoCmd.OpenReport "rscaletickets08",
WhereCondition:=strCriteria
                                 Else
                            MsgBox "Name not found", vbInformation,
"Warning"
                          End If
                        End Sub
There seems to be some sort of data type mismatch. I know it's
something simple but just can't seem to get it.  Could it be because
of the strCriteria As String?
Any help would be appreciated.

Thanks,
rkg

proper delimiter for a date field is #, so it should be
strCriteria = "entry_date = "# & Me.Combo7 & "#"
 

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