473,395 Members | 1,577 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.

Query Syntax Problem

Can someone please tell me - what's the problem with the syntax of the
Select portion of the call to the ChangeQueryDef function. My " " marks are
off - but I can't figure out where -

Private Sub cboSelectPhys_Change()
Dim rsA As DAO.Recordset
Dim strSQL As String

'select the records which have the same Full dr's name as that
'selected in the combobox
Set rsA = CurrentDb.OpenRecordset("Select * from qryLkpPhys where [Physician
Name]= '" & cboSelectPhys.Value & "'", dbOpenDynaset)

rsA.MoveFirst
rsA.MoveLast
Debug.Print "recordcount= "; rsA.RecordCount
If rsA.RecordCount > 0 Then
rsA.MoveFirst
strSQL = "'" & rsA("MD#") & "'"
rsA.MoveNext
Do Until rsA.EOF
strSQL = strSQL & " OR '" & rsA("MD#") & "'"
rsA.MoveNext
Loop
End If
Debug.Print "strSql= "; strSQL

ChangeQueryDef "qryPhysRpt", "SELECT Docname, Patient,Q6 from qryPhysName
where Q12=(" & "'" & strSQL & "')" _
& " OR Q13=(" & "'" & strSQL & "')" & _
" OR Q14=(" & "'" & strSQL & "')" & _
" OR Q15=(" & "'" & strSQL & "')"

Thanks!
Andi


Nov 13 '05 #1
1 1134
Andi Plotsky wrote:
Can someone please tell me - what's the problem with the syntax of the Select portion of the call to the ChangeQueryDef function. My " " marks are off - but I can't figure out where -

...
Thanks!
Andi


Here's what I tried:

I changed the creation of strSQL to use commas instead of OR's.

where Q12 IN (" & strSQL & ")" & " OR Q13 IN (" & strSQL & ")" & ...

created:

where Q12 IN ('12','15') OR Q13 IN ('12','15') ...

Note that if Q12 and Q13 are Long fields you should create strSQL so
that the final string looks like:

where Q12 IN (12,15) OR Q13 IN (12,15) ...
These queries ran correctly in my test examples.

James A. Fortune

Nov 13 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: joemyre | last post by:
Hi everyone, What I'm trying to do is take php variables i got from user input, and pass them as the MySQL query terms. $query = "select * from ident where ".$searchtype1."=".$searchterm1."";...
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"...
0
by: Arnold | last post by:
Hi, I'm using visual studio .NET 2003 enterprise and MySQL 5.0. I've created a database project in wich I like to create scripts for stored procedures and queries. I've created a connection...
3
by: KevLow | last post by:
Hi, Hope some kind soul can help me out here.. I'm trying to programmatically modify the column headings of a crosstab query such that it can be dynamic based on user specified period (Month...
1
by: Crash | last post by:
Hi, ..NET v1.x SP1 VS 2003 SQL Server 2000 SP3 Server 2000, XP, Server 2003 I would like to programmatically execute {possibly many} SQL Server batch scripts. Aka I have many scripts that...
7
by: John Øllgård Jensen | last post by:
Hi Using MS Asccess 2000: In a query I'm trying to create a new field with following expression: FilmDate: Left(,4) The field "FilmNo" is another text field in the query. This is...
7
by: KoliPoki | last post by:
Hello every body. I have a small issue. Problem: I have a table with 4 descriptor columns (type). I need to formulate a query to retrieve a count for each type so I can group by...etc. The...
10
by: Daniel | last post by:
In Microsoft Access I can write a query that includes the criteria: Between Date()-7 And Date() to retrieve the records from a table that fall within the last week. I'm trying to write a...
2
by: Flic | last post by:
Hi, I have a basic db that I access with MySQL query browser. Everything seems fine to me but I am using this db as part of a php shopping basket and when I try to add an item I get: Notice:...
7
by: bryant | last post by:
Hi all. I am new to ASP and working in Expression Web. The following query displays the information I need in the gridview for a single record. SELECT "OE_HDR"."ORD_NO", "OE_HDR"."CUST_NAM",...
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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.