Help With SQL Syntax

  • Thread starter Thread starter Terrence
  • Start date Start date
T

Terrence

Hi All

I need help with SQL Syntax. How do I use a variable in an
SQL Statement

example

Sub test()
dim T as string
T = forms!frmTest.TxtUser

DoCmd.RunSQL "SELECT T.Field1,INTO TestTable FROM T"

End Sub

I hope somebody out there can help me.

Thanks In Advance
 
Two issues:

1. RunSql is for action queries. Use a form (in Datasheet view if you like)
for the user interface. You can assign the RecordSource of the form, or
apply a filter.

2. Concatenate the value from the form into the SQL string, e.g.:
"SELECT ... " & T
 
Back
Top