Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help in changing the datatype of this code 1

Status
Not open for further replies.

Taecca

Technical User
Jul 20, 2004
59
US
I have changed a field in my table.
strName should be datatype date

cboDateSent now has a data instead of a text value.

How do I modify the following code to make it work?
I am not getting a data mismatch.



Private Sub cmdOpenDateSentReport_Click()
On Error GoTo Err_cmdOpenDateSentReport_Click

Const conErrorEmptyField = 94
Dim strName As String
Dim strDocName As String

strName = Me.cboDateSent
strDocName = "rptDateSent"

If strName = "All Dates" Then
DoCmd.OpenReport strDocName, acPreview
Else

DoCmd.OpenReport strDocName, acPreview, , "DateSent1= '" & strName & " ' OR DateSent2= '" & strName & " ' OR DateSent3= '" & strName & " '"
End If
Exit_cmdOpenDateSentReport_Click:
Exit Sub

Err_cmdOpenDateSentReport_Click:
If Err.Number = conErrorEmptyField Then
MsgBox ("Please select a date")
Else
MsgBox Err.Description
End If
Resume Exit_cmdOpenDateSentReport_Click
End Sub
 
Are DateSent1 through 3 data type Date/Time? If so, try replacint the single quotes with pound signs:

DoCmd.OpenReport strDocName, acPreview, , "DateSent1= #" & strName & "# OR DateSent2= #" & strName & "# OR DateSent3= #" & strName & "#"


-Gary
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top