Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 1 / January 2006

Tip: Looking for answers? Try searching our database.

Syntax error (missing operator) in query expression

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jodyblau - 28 Jan 2006 21:10 GMT
I'm new at this stuff, so bare with me.

I have a main form which displays a client record.
The main form has 2 subforms.  The first subform has a list of Cases.
The Second subform is a list of Tasks.

My intent is this:  When I click on a button next to one of the Case
records (in the first subform), I want the list of Tasks (the second
subform) to display only those records (tasks) associated with the Case
which was just selected.

Here is what I have attempted:

Private Sub View_Tasks_Click()
On Error GoTo Err_View_Tasks_Click

  GBL_String = Case_or_Issue

   strSQL = "Select * from Task_List where"
   strSQL = strSQL & " " & Case_or_Issue & " =" & GBL_String
   Forms!Case_List_By_Clients!Task_List.Form.RecordSource = strSQL

Exit_View_Tasks_Click:
   Exit Sub

Err_View_Tasks_Click:
   MsgBox Err.Description
   Resume Exit_View_Tasks_Click

End Sub

Note:  The Case_or_Issue that is used to assign a value to GBL_String
identifies the record selected from the first subform.  My Task_List
(second subform) also has a field called Case_or_Issue.  So I am trying
to compare the two strings and filter the form accordingly.

When I try this, I get "Syntax error (missing operator) in query
expression"
While trouble shooting, I removed the second part of strSQL, and
removed "where" from the first part, so as to just select all records.
This produces no errors.

Can someone help me understand how to solve this error?

Thank You,

Jody Blau
MGFoster - 28 Jan 2006 23:43 GMT
If the Tasks is a datasheet form, why don't you make the Tasks a subform
of the Cases subform?  Then everytime you move to a new case the tasks
subform will automatically display the appropriate Tasks.

See the Help articles on Master and Child link fields.
Signature

MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

> I'm new at this stuff, so bare with me.
>
[quoted text clipped - 39 lines]
>
> Can someone help me understand how to solve this error?
jodyblau - 29 Jan 2006 05:14 GMT
I have it in a continous form, rather than a datasheet, so it won't let
me do the subform in the subform.
Bob Quintal - 29 Jan 2006 14:32 GMT
> I have it in a continous form, rather than a datasheet, so it
> won't let me do the subform in the subform.

A technique I've used successfully is to put a hidden textbox on
the mainform that contains the primary key for subform_1. the
control is unbound, but gets updated in the Current event of
subform_1. Subform_2's link parent fields property is set to thae
textbox. Just clicking on a record in subform_1 resynchronises the
subform_2.


Signature

Bob Quintal

PA is y I've altered my email address.

Lyle Fairfield - 28 Jan 2006 23:57 GMT
Air Script (assumes GBL_String's type is String)

strSQL = "SELECT * FROM Task_List"
strSQL = strSQL & vbNewLine & "WHERE Case_or_Issue  = '" & GBL_String
& "'"

'" is one of these ' and one of these "

"'" is one of these ", then one of these ', and another one of these"
Bob Quintal - 29 Jan 2006 00:25 GMT
> Air Script (assumes GBL_String's type is String)
>
[quoted text clipped - 6 lines]
> "'" is one of these ", then one of these ', and another one of
> these"

Interesting use of vbNewLine where a space would work. I could see3
a benefit for readability if saving the string to a querydef, but
what advantage would it offer in this scenario?

Signature

Bob Quintal

PA is y I've altered my email address.

jodyblau - 29 Jan 2006 05:18 GMT
Bob Quintal - 29 Jan 2006 00:18 GMT
> I'm new at this stuff, so bare with me.

I don't bare with anybody unless they are really cute. I will
bear with you, as in help bear your problem on my shoulders.

> I have a main form which displays a client record.
> The main form has 2 subforms.  The first subform has a list of
[quoted text clipped - 13 lines]
>     strSQL
> Can someone help me understand how to solve this error?

Case_or_issue is a field in the table Task_List?
It miust be put into the SQL as a literal.

strSQL = strSQL & " Case_or_Issue = " & GBL_String

GBL_String is a string, right? The3 above would work if it's a
number, but it must be surrounded by quotes in the SQL. You
insert quotes in a variable by putting two quotes side by side.:

strSQL = strSQL & " Case_or_Issue =""" & GBL_String & """"

Signature

Bob Quintal

PA is y I've altered my email address.

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.