473,385 Members | 1,312 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,385 software developers and data experts.

SQL error

26
Background: Front End MS Access 2010 with VBA; Backend SQL Server 2008; Still learning SQL

I have the following statement coded
Expand|Select|Wrap|Line Numbers
  1. gblsSQL = "Select Role FROM [dbo_UserProgram] Where Program='Security' IDUser=" & gblID & ";"
It is generating this error: Run-time error (missing operator) in query expression Program='Security' IDUser=1'. What is wrong?
Thanks in advanced.
Nov 10 '14 #1
8 1008
Seth Schrock
2,965 Expert 2GB
You are missing the comma between your two criteria. You should have
Expand|Select|Wrap|Line Numbers
  1. gblsSQL = "Select Role FROM [dbo_UserProgram] Where Program='Security' AND IDUser=" & gblID & ";"
Nov 10 '14 #2
zmbd
5,501 Expert Mod 4TB
Please place a "stop" either before or after the string.
execute to the stop.
Then <ctrl><g>
Then in the immediate window type
Expand|Select|Wrap|Line Numbers
  1. ?gblsSQL
[enter]
(also appears to be missing comma)
Cut and paste back the resolved string.
Nov 10 '14 #3
CLSkcab
26
I did as you requested and put in (,). This time I get the following message: Run-time error 3075, Syntax error (comma) in query expression 'Program='Security', IDUser=1'
Nov 10 '14 #4
zmbd
5,501 Expert Mod 4TB
Please do the troubleshooting step as outlined in my post.
Nov 10 '14 #5
Seth Schrock
2,965 Expert 2GB
Oh, duh. The WHERE clause needs the word And or Or for multiple criteria. See my fix in post #2. And please do post the information requested by zmbd.
Nov 10 '14 #6
CLSkcab
26
I have a SQL table record:

ID int primary key
IDUser int secondary key points to the parent
Program varchar(50)
Role varchar(5)
.
.
.

I know the secondary key and program values. Hoe can I get the Role value? Any help will be appreciated. I did find where you can't use a Select like this.
Nov 10 '14 #7
zmbd
5,501 Expert Mod 4TB
CLSkcab,

What we need to see here is the code that you are using and the resolved string as requested.

You can indeed retrieve the information you are looking for using a select query as the recordset-object. You only need to provide a clear question and enough detail for us to proceed.
(^_^)
Nov 11 '14 #8
Luuk
1,047 Expert 1GB
see first reply of 'Seth Schrock' where he said this (i only quote the SQL):
Expand|Select|Wrap|Line Numbers
  1. Select Role 
  2. FROM [dbo_UserProgram] 
  3. Where Program='Security' 
  4.   AND IDUser=" & gblID & ";"
  5.  
  6.  
Nov 12 '14 #9

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

Similar topics

13
by: deko | last post by:
I use this convention frequently: Exit_Here: Exit Sub HandleErr: Select Case Err.Number Case 3163 Resume Next Case 3376 Resume Next
7
by: p | last post by:
WE had a Crystal 8 WebApp using vs 2002 which we upgraded to VS2003. I also have Crystal 9 pro on my development machine. The web app runs fine on my dev machine but am having problems deploying....
1
by: developer | last post by:
Hi All I have made a .NET project. the files included are borland c++ files that i am migrate to VC++ .NET I am using Microsoft Visual C++ .NET 2003. the compilation goes through properly,...
2
by: f rom | last post by:
----- Forwarded Message ---- From: Josiah Carlson <jcarlson@uci.edu> To: f rom <etaoinbe@yahoo.com>; wxpython-users@lists.wxwidgets.org Sent: Monday, December 4, 2006 10:03:28 PM Subject: Re: ...
2
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
15
by: madhu.ab | last post by:
Hi All, I am getting the following errors when i am including header file winuser.h I dont know whats happening. How will an error occur in winuser.h?? Please help. \microsoft visual...
0
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
5
by: yashu0209 | last post by:
I have an error occurring when i try to compile the program and the error is: D:\Program Files\visual studio 6.0\MSDev98\MyProjects\GLEnabledView\GLNew.cpp(164) : error C2653: 'CGLEnabledView' :...
2
by: randa zaghdan | last post by:
Hi I have a problem with my program in vc 2008 When I compile it, the following errors are listed. I try to resolve it but no hope Does any one can help me ? thanks . Linking......
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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...

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.