|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
RunSQL with a variable
Hi,
I trying to a Runsql command in access using a variable example MyVar = 25 DoCmd.runsql ("Select Name, Age From People Where Age = MyVar") However this comes up with an error The validation is fine Any help would be great Thanks!!!! |
|
#2
|
|||
|
|||
|
DoCmd.runsql ("Select Name, Age From People Where Age = " & MyVar)
|
|
#3
|
|||
|
|||
|
What about the semi colon. We it look like this
DoCmd.runsql ("Select Name, Age From People Where Age = " & MyVar & ";") Thanks |
|
#4
|
|||
|
|||
|
Its coming up with " A Runsql actions requires an argument consisting of a SQL Statement
Last edited by cunliffe : December 9th, 2003 at 12:41 PM. |
|
#5
|
||||
|
||||
|
don't use the semicolon, either use
Code:
DoCmd.runsql ("Select Name, Age From People Where Age = " & MyVar)
or Code:
DoCmd.runsql ("Select Name, Age From People Where Age LIKE '" & MyVar & "'")
__________________
Fisherman "Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius -- and a lot of courage -- to move in the opposite direction." - A.Einstein |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > RunSQL with a variable |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|