How do I stop this error message?

  • Thread starter Thread starter Tony Williams
  • Start date Start date
T

Tony Williams

I have a form that has a command button that when clicked selects a record
based on information on the form. One of the form controls is a combo box
where the user selects an appropriate date. This is mandatory and I have a
message box that pops up to warn the user they must enter the date. However
I also get an error message Runtime error 3075 and then details of the
missing data for my code. How do I stop this error message from appearing?
Thanks
Tony
 
Posting the code might help...

3075 is a Syntax error, so you must be formatting something as text
when it should be a date, or vice-versa, or something similar.
 
Thanks.
here is my code
Private Sub cmdok_Click()
Dim strform As String 'Name of report to open.
Dim strField As String 'Name of your date field.
Dim strWhere As String 'Where condition for OpenReport.
Const conDateFormat = "\#mmmm\/yyyy\#"

strform = "frmFDAfindb"
strField = "txtmonthlabel"

If IsNull(Me.txtdate) Then
MsgBox "You must select the appropriate quarter", vbOKOnly, "Incorrect
Qtr Date"
Else
strWhere = strField & " = " & Format(Me.txtdate, conDateFormat)
End If

If Not IsNull(Me.cmbselectcompany) Then
strWhere = strWhere & " AND txtcompany = """ & Me.cmbselectcompany & """"
End If
'strWhere = Mid(strWhere, 6) 'get rid of extra AND
'Debug.Print strWhere 'For debugging purposes only.
DoCmd.OpenForm strform, acNormal, , strWhere

End Sub

Can you tell me where the syntax error is?
Tony
 
Back
Top