M
Mkauley
After realizing that Macro's were a bit limiting, I decided to begin coding
VB for my buttons. So, to that end, I'm trying to get a button to open a
product release sheet for a specific date range (basically everything from
the last two months up through the next 3 months). This is the VB code I use
for the button. It seems to work except that I get an error of "Data type
mismatch in criteria expression"
The Release Date field used is set up as a date field and if I change the
where clause to look at, say, a specific product code in the product code
field, it works fine. Apologies in advance if this isn't the right forum to
post in.
The code is:
Private Sub Command39_Click()
On Error GoTo Err_Command39_Click
Dim st3MonthCond As String
st3MonthCond = "[qryNRSheet]![Release Date]=""Between
DateAdd(m,-2,Date)And DateAdd(m,3,Date)"""
DoCmd.OpenReport "New Release Sheet Report", acViewPreview, , st3MonthCond
Exit_Command39_Click:
Exit Sub
Err_Command39_Click:
MsgBox Err.Description
Resume Exit_Command39_Click
End Sub
VB for my buttons. So, to that end, I'm trying to get a button to open a
product release sheet for a specific date range (basically everything from
the last two months up through the next 3 months). This is the VB code I use
for the button. It seems to work except that I get an error of "Data type
mismatch in criteria expression"
The Release Date field used is set up as a date field and if I change the
where clause to look at, say, a specific product code in the product code
field, it works fine. Apologies in advance if this isn't the right forum to
post in.
The code is:
Private Sub Command39_Click()
On Error GoTo Err_Command39_Click
Dim st3MonthCond As String
st3MonthCond = "[qryNRSheet]![Release Date]=""Between
DateAdd(m,-2,Date)And DateAdd(m,3,Date)"""
DoCmd.OpenReport "New Release Sheet Report", acViewPreview, , st3MonthCond
Exit_Command39_Click:
Exit Sub
Err_Command39_Click:
MsgBox Err.Description
Resume Exit_Command39_Click
End Sub