DoCmd.RunSQL

message from =?Utf-8?B?Sk1vcnJlbGw=?= on 17 May 2004
<shaking my head again>

sqlStatement = "select tblvehicles.vehid from tblvehicles where tblvehiclesvehid = " & Me.txtVehID & ";"

DoCmd.RunSQL sqlStatement

gives me the error: "A RunSQL action requires an argument consisting of an SQL statement." ?

tia,
 
Kevin3NF replied to =?Utf-8?B?Sk1vcnJlbGw=?= on 17 May 2004
sqlStatement = "select tblvehicles.vehid from tblvehicles where tblvehicles
. vehid = " & Me.txtVehID & ";"

Are you missing a dot in the where clause? remove the spaces dded for
exaggeration
 
Kevin3NF replied to =?Utf-8?B?Sk1vcnJlbGw=?= on 17 May 2004
And your SQL Statement is not an action query, such as Update or delete.
 
=?Utf-8?B?Sk1vcnJlbGw=?= replied to Kevin3NF on 17 May 2004
Of course... somehow I knew that. I'm trying to validate a users data entry of a value in another table. Is there a more elegant way of doing this?

again, tia
 
Pavel Romashkin replied to =?Utf-8?B?Sk1vcnJlbGw=?= on 17 May 2004
Try

Dim Rst as ADODB.Recordset
Set Rst = New ADODB.Recordset
Rst.Open "your sql here", CurrentProject.Connection
Rst.MoveFirst
IF Rst.EOF then MsgBox "No data matches your criteria"
Rst.Close
Set Rst = Nothing

Pavel

JMorrell wrote:
 
tina replied to =?Utf-8?B?Sk1vcnJlbGw=?= on 17 May 2004
if the user's data entry has to match a value from another table, is it
feasible in your setup to use a combo box for the data entry? with the
LimitToList property set to Yes, the validation is automatic.

hth

"JMorrell" <anonymous@discussions.microsoft.com> wrote in message
news:77DEB0EF-52BD-43F7-81D7-08D0632DACB4@microsoft.com...
entry of a value in another table. Is there a more elegant way of doing
this?
 
=?Utf-8?B?Sk1vcnJlbGw=?= replied to tina on 17 May 2004
I love it! Simplicity (well, almost) at its best. There's always something new to learn with Access.

thank you!
 
Pavel Romashkin replied to tina on 18 May 2004
Yet, people ofted get upset when you try to suggest another solution to
their problem than the one they posted. OP is the exception.
This is why I like ?s like "how can I" rather than "why is my 70 line
SQL isn't working". Chances are, there is a 2-line solution if you knew
the entire original problem.

Pavel

tina wrote:
 
tina replied to Pavel Romashkin on 18 May 2004
yes, that happens sometimes. but everyone here posts possible solutions with
good intent, and multiple possible solutions can give the requester a choice
of what is easiest and most understandable *for him/her* - and that varies
depending on the person. multiple solutions posted to a question also offer
all of us a chance to learn from each other - i know i very often learn a
lot from the differing solutions others put forth, whether or not i also
posted one. :)

"Pavel Romashkin" <pavel_romashkin@hotmail.com> wrote in message
news:40AA4914.13B4B5CA@hotmail.com...
 
Dirk Goldgar replied to =?Utf-8?B?Sk1vcnJlbGw=?= on 17 May 2004
"JMorrell" <anonymous@discussions.microsoft.com> wrote in message
news:F4883F79-689D-43AA-9AD4-757D895FAC12@microsoft.com

The message is a bit misleading. What it's trying to tell you is that
the argument must be an *action* query -- that is, an update, delete,
append, or make-table query. A select query can't be executed by
RunSQL.
 

Archived message: DoCmd.RunSQL (Microsoft Access Forms)