I am new to SQL, I have no idea what I am doing wrong here:
dim strSQL as string
strSQL = "SELECT [field],[field] FROM [table] WHERE [field] = "
& g_strVariable
When I try to run it it tells me that the paramters are wrong but is i take the global vairable out and manually add a string it works fine. I know the globale has the string in it because i checked it with a message box and it outputed the correct string...any help
Comments
:
: dim strSQL as string
:
: strSQL = "SELECT [field],[field] FROM [table] WHERE [field] = "
: & g_strVariable
:
: When I try to run it it tells me that the paramters are wrong but is i take the global vairable out and manually add a string it works fine. I know the globale has the string in it because i checked it with a message box and it outputed the correct string...any help
:
Double check that all the fields are named correctly as this is a common mistake
Also try using single quotes around the varible
[code]Dim strSQL as string
strSQL = "SELECT [field],[field] FROM [table] WHERE [field] = '"
& g_strVariable & "'"[/code]
: :
: : dim strSQL as string
: :
: : strSQL = "SELECT [field],[field] FROM [table] WHERE [field] = "
: : & g_strVariable
: :
: : When I try to run it it tells me that the paramters are wrong but is i take the global vairable out and manually add a string it works fine. I know the globale has the string in it because i checked it with a message box and it outputed the correct string...any help
: :
: Double check that all the fields are named correctly as this is a common mistake
:
: Also try using single quotes around the varible
:
: [code]Dim strSQL as string
:
: strSQL = "SELECT [field],[field] FROM [table] WHERE [field] = '"
: & g_strVariable & "'"[/code]
:
:
:
:
: Simon Thwaites - IT Consultant
: Simon@fhdale.co.uk
: Simon@vbsnippets.co.uk
:
: