473,395 Members | 1,783 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Syntax, Missing Operator

23
I have a form where I enter the Agent Name, Session Type, Start and End Dates. I’ve done this in the past but not with a Between statement and have not had a problem. I use the code below to put together a statement with the parameters I enter in the form.

I’m not a programmer so I’m not sure what the syntax problem is. I'm hoping someone can help me with this. Thanks in advance.

This is the error I am receiving after entering the four fields:

Syntax error (missing operator) in query expression ‘(txtAgentName=”Angela Sobczak” AND txtSessionType=”Coaching Session” AND (dtmSessionDate) = Between #01/01/2012# AND #02/01/2012#)’

This is the code that puts everything together.

Private Sub cmdApplyFilter_Click()

Dim strFilter As String
Dim dtmStartDate As Date
Dim dtmEndDate As Date

‘Agent Name
If Not IsNull(Me.cboAgentName) Then
strFilter = strFilter & " AND txtAgentName=""" & Me.cboAgentName & """ "
End If

'Session Type
If Not IsNull(Me.cboSessionType) Then
strFilter = strFilter & " AND txtSessionType=""" & Me.cboSessionType & """ "
End If

‘Start and End Dates
If Not (IsNull(Me.dtmStartDate) Or Me.dtmStartDate = "") Then
strFilter = strFilter & " AND (dtmSessionDate) = Between #" & Format(Me.dtmStartDate, "mm/dd/yyyy") & "# AND #" & Format(Me.dtmEndDate, "mm/dd/yyyy") & "#"
End If

'If the report is closed, open the report
If SysCmd(acSysCmdGetObjectState, acReport, "rptCalls") <> acObjStateOpen Then
DoCmd.OpenReport "rptCalls", acPreview
End If

'if report was open, use filter
With Reports![rptCalls]
.Filter = Mid(strFilter, 6)
.FilterOn = True
End With

End Sub
Jun 19 '12 #1

✓ answered by BikeToWork

Expand|Select|Wrap|Line Numbers
  1. AND (dtmSessionDate) = Between #" & Format(Me.dtmStartDate, "mm/dd/yyyy") & "# AND #" & Format(Me.dtmEndDate, "mm/dd/yyyy") & "#"
I think you've got an extra "=" sign in this statement. I'm not sure that is causing the syntax error but it should be:

Expand|Select|Wrap|Line Numbers
  1. AND (dtmSessionDate) Between #" & Format(Me.dtmStartDate, "mm/dd/yyyy") & "# AND #" & Format(Me.dtmEndDate, "mm/dd/yyyy") & "#"

2 1876
BikeToWork
124 100+
Expand|Select|Wrap|Line Numbers
  1. AND (dtmSessionDate) = Between #" & Format(Me.dtmStartDate, "mm/dd/yyyy") & "# AND #" & Format(Me.dtmEndDate, "mm/dd/yyyy") & "#"
I think you've got an extra "=" sign in this statement. I'm not sure that is causing the syntax error but it should be:

Expand|Select|Wrap|Line Numbers
  1. AND (dtmSessionDate) Between #" & Format(Me.dtmStartDate, "mm/dd/yyyy") & "# AND #" & Format(Me.dtmEndDate, "mm/dd/yyyy") & "#"
Jun 19 '12 #2
AnnMV8
23
Thank you so much, that worked.
Jun 19 '12 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: alexz | last post by:
valuA = (request.form("toadd")) If valuA = "" then SQL = "UPDATE CourseReg SET attended='Active' WHERE ID IN("&request.form("toadd")&")" Set RS = MyConn.Execute(SQL) End If MyConn.Close Set...
29
by: shank | last post by:
1) I'm getting this error: Syntax error (missing operator) in query expression on the below statement. Can I get some advice. 2) I searched ASPFAQ and came up blank. Where can find the "rules"...
3
by: Mark | last post by:
Hi - I can get this to work in SQL Server - but when also trying to make the application compatible with MS Access I get an error: Select tblfaqnetgroups.group_name from tblfaqnetroles Inner...
4
by: dcarson | last post by:
I've read about this error in several other discussions, but still can't seem to pinpoint the problem with my code. Everything seemed to be working fine for some time, but it now tends to bomb out...
1
by: Alan Murrell | last post by:
Hello, One of our web hosting clients is getting the following error when someone tried to log in form their login page: --- ODBC ERROR --- Microsoft OLE DB Provider for ODBC Drivers error...
1
by: JMCN | last post by:
I have an ftp program that i inherited and i tried to modify it to ftp over my file however, i receive an error message : run-time error '3075 syntax error (missing operator) in query expression...
4
by: khan | last post by:
getting, error, 3075 Syntax Error (Missing Operator) in query expression '8WHERE .=1' Dim TotalQty As Integer TotalQty = DLookup("", "", "=" & Forms!!)
3
by: access baby | last post by:
I hava a date parameter filter query but it shows error Syntax error missing operator in query experssion can some one please help where am i going wrong in expression SELECT copyorderdtl * ...
23
by: Audrey Abbey | last post by:
I have a piece of code (below) that is giving me fits. I copied this code from elsewhere on the net, and I have been fiddling with the quotations in the Where clause, as that seems to be the problem....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.