T
TonyWilliams via AccessMonster.com
Could someone tell me why I'm getting an Expected end of statement with this
code:
Private Sub cmdopenrecord_Click()
On Error GoTo Err_cmdopenrecord_Click
Dim dtmFirstDay As Date
Dim dtmLastDay As Date
Dim strtxtcompany As String
Dim strdeal As Integer
'set strtxtsurname equal to the selected value before closing the form,
otherwise it will give us an error
strtxtcompany = Me.txtcompany.Value
strdate = Me.txtmontha
strdeal = Me.txtdealnbr
dtmFirstDay = DateSerial(Year(Me.txtsearch2), Month(Me.txtsearch2), 1)
dtmLastDay = DateSerial(Year(Me.txtsearch2), Month(Me.txtsearch2) + 1, 0)
Forms!frmMain!SubForm1.SourceObject = "frmhighvaluedeals"
Forms!frmMain!SubForm1.Form.RecordSource = "SELECT * FROM [qrysearchHV]
WHERE [txtcompany] = '" & strtxtcompany & "'" & _
"AND ([txtmonth] Between " & _
Format(dtmFirstDay, "\#yyyy\-mm\-dd\#") & _
" AND " & Format(dtmLastDay, "\#yyyy\-mm\-dd\#") & ") & _
" AND [txtdealnbr]=strdeal"
Exit_cmdopenrecord_Click:
Exit Sub
Err_cmdopenrecord_Click:
MsgBox Err.Description
Resume Exit_cmdopenrecord_Click
End Sub
The line that is highlighted is this one
" AND [txtdealnbr]=strdeal"
Thanks in advance
Tony
code:
Private Sub cmdopenrecord_Click()
On Error GoTo Err_cmdopenrecord_Click
Dim dtmFirstDay As Date
Dim dtmLastDay As Date
Dim strtxtcompany As String
Dim strdeal As Integer
'set strtxtsurname equal to the selected value before closing the form,
otherwise it will give us an error
strtxtcompany = Me.txtcompany.Value
strdate = Me.txtmontha
strdeal = Me.txtdealnbr
dtmFirstDay = DateSerial(Year(Me.txtsearch2), Month(Me.txtsearch2), 1)
dtmLastDay = DateSerial(Year(Me.txtsearch2), Month(Me.txtsearch2) + 1, 0)
Forms!frmMain!SubForm1.SourceObject = "frmhighvaluedeals"
Forms!frmMain!SubForm1.Form.RecordSource = "SELECT * FROM [qrysearchHV]
WHERE [txtcompany] = '" & strtxtcompany & "'" & _
"AND ([txtmonth] Between " & _
Format(dtmFirstDay, "\#yyyy\-mm\-dd\#") & _
" AND " & Format(dtmLastDay, "\#yyyy\-mm\-dd\#") & ") & _
" AND [txtdealnbr]=strdeal"
Exit_cmdopenrecord_Click:
Exit Sub
Err_cmdopenrecord_Click:
MsgBox Err.Description
Resume Exit_cmdopenrecord_Click
End Sub
The line that is highlighted is this one
" AND [txtdealnbr]=strdeal"
Thanks in advance
Tony