RunSQL

G

Guest

I want use DoCmd.RunSQL to select the name of a client and then assign the
query result to a variable or text box on a form. I get error: Runtime 3129.
Is there a way to do this?


Dim strSQLFirstName As String, strFirstName As String

strSQLFirstName = "SELECT dbo_Client.FirstName " & _
"FROM dbo_Client " & _
"WHERE (((dbo_Claimant.SSN)=[Forms]![frmDataEntry]![txtNumber));"

DoCmd.RunSQL strSQLFirstName = strFirstName

me.txtFirstName = strFirstName
 
B

Bob Hairgrove

I want use DoCmd.RunSQL to select the name of a client and then assign the
query result to a variable or text box on a form. I get error: Runtime 3129.
Is there a way to do this?


Dim strSQLFirstName As String, strFirstName As String

strSQLFirstName = "SELECT dbo_Client.FirstName " & _
"FROM dbo_Client " & _
"WHERE (((dbo_Claimant.SSN)=[Forms]![frmDataEntry]![txtNumber));"

DoCmd.RunSQL strSQLFirstName = strFirstName

me.txtFirstName = strFirstName

Use DLookup instead.
 
G

Guest

The RunSql will run update query only (update, insert, delete) but not a
select query

Instead use:

me.txtFirstName = Dlookup("FirstName","Client","SSN =
[Forms]![frmDataEntry]![txtNumber]")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top