Wrox Home  
Search P2P Archive for: Go

  Return to Index  

sql_language thread: Missing Operator


Message #1 by robert_s_johnson1944@n... on Mon, 25 Nov 2002 14:56:59
>The problem has been solved. The SQL statement became:

pstrSQL = "SELECT txtCrFSPgmNum, txtPCA, txtCFSPgmNam, txtLQDate FROM 
tblSCOA " & _
"WHERE txtCrFSPgmNum = '" & mstrSubPgm & "' ORDER BY [txtCrFSPgmNum] 

The mstrSubPgm now has '"  "' around it.  Thanks to all who provided 
suggestions and contributed to the solution.

>I changed the code. Now I am getting; Syntax error(missing operator) in 
q> uery expression 'txCrFSPgmNum = 2B10'. The 2B10 is the variable 
m> strSubPgm. Here's the way the code looks now.

> Dim pstrSQL As String

> mstrSubPgm = InputBox("Enter the sub-program number you are interested 
i> n.")

> 'Ensures that any characters entered are upper case as they are in the 
DB.
m> strSubPgm = UCase$(mstrSubPgm)

> pstrSQL = "SELECT txtCrFSPgmNum, txtPCA, txtCFSPgmNam, txtLQDate FROM 
t> blSCOA " & _
"> WHERE txtCrFSPgmNum = " & mstrSubPgm & " ORDER BY [txtCrFSPgmNum] "
 >    
a> dSubPgm.RecordSource = pstrSQL
a> dSubPgm.Refresh
d> bgSubPgm.Refresh

> 
y> ou are including the *name* of the variable holding your search 
criteria 
a> nd *NOT*
t> he value of that variable.  change you select to this:

> pstrSQL = "SELECT txtCrFSPgmNum, txtPCA, txtCRFSPgmNam, txtLQDate FROM 
 > tblSCOA " & _
 > "WHERE txtCrFSPgmNum = " & mstrSubPgm & " ORDER BY [txtCrFSPgmNum] "

> see how i stop building the select string, then append the variable 
m> strSubPgm -
t> hat will insert the value of the variable (which is what you want) into 
t> he string.

> before, Access was looking for a field named "mstrSubPgm" - which 
o> bviously, doesn't
e> xist.

> that should fix your problem.

> enjoy.

> john

> 

> John Pirkey
M> CSD
h> ttp://www.stlvbug.org

> 

> --- robert_s_johnson1944@n... wrote:
>>  I moved the where clause to the end. Now I am getting an error tha 
>>  says "No values given for one or more required parameters." I thought 
t> his 
>>  might be because the LQDate has nulls. However when I remove it from 
the 
>>  select statement I still get the error message.
>>  
>>  
>>  > The where clause should come before the order by:
>>  pstrSQL = "SELECT txtCrFSPgmNum, txtPCA, txtCRFSPgmNam, txtLQDate FROM 
>>  tblSCOA " & _
>>  "WHERE txtCrFSPgmNum =  mstrSubPgm ORDER BY [txtCrFSPgmNum] "
>>  
>>  Brian Freeman
>>  Carnegie Technology and Bluewave Computing
>>   (xxx) xxx-xxxx  ext. 415
>>  www.carnegie.com   / www.bluewave-computing.com
>>  
>>  
>>  -----Original Message-----
>>  From: robert_s_johnson1944@n...
>>  [mailto:robert_s_johnson1944@n...]
>>  Sent: Monday, November 25, 2002 9:57 AM
>>  To: sql language
>>  Subject: [sql_language] Missing Operator
>>  
>>  
>>  I am trying to use the following code to input a value then have that 
>>  value matched with a value in an Access DB; then have the ADODC 
s> ychronize 
>>  with a Data Grid (DG) which causes the DG's arrow to point to the 
record 
>>  associated with the value entered in the InputBOX.
>>  
>>  Private Sub mnuSubProgram_Click()
>>  Dim pstrSQL As String
>>  
>>  mstrSubPgm = InputBox("Enter the sub-program number you are interested 
>>  in.")
>>  mstrSubPgm = UCase$(mstrSubPgm)
>>  
>>  pstrSQL = "SELECT txtCrFSPgmNum, txtPCA, txtCRFSPgmNam, txtLQDate FROM 
>>  tblSCOA " & _
>>  "ORDER BY [txtCrFSPgmNum] WHERE txtCrFSPgmNum =  mstrSubPgm"
>>      
>>  adSubPgm.RecordSource = pstrSQL
>>  adSubPgm.Refresh
>>  dbgSubPgm.Refresh
>>  
>>  I am getting an error message that says... Syntax error(missing 
o> perator) 
>>  in query expression '[txtCrFSPgmNum where TXTCRFSPgmNum = mstrSubPgm. 
I 
>>  thought ORDER BY was the operator. I have retyped the line thinking I 
h> ave 
>>  too many or too few spaces without any luck. What Am I missing?
>>  
>>  
>>  ---
>>  Change your mail options at http://p2p.wrox.com/manager.asp or 
>>  to unsubscribe send a blank email to
>>  
>>  
>>  ---
>>  Change your mail options at http://p2p.wrox.com/manager.asp or 
>>  to unsubscribe send a blank email to 

> 
_> _________________________________________________
D> o you Yahoo!?
Y> ahoo! Mail Plus ? Powerful. Affordable. Sign up now.
h> ttp://mailplus.yahoo.com

  Return to Index