Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dim statement question 2

Status
Not open for further replies.

Kurt6905

Technical User
Aug 21, 2006
14
0
0
US
Hello. For the following VBA program, Access does not like my Dim statement. How do I assign the table (or recordset) I want converted to "rs?"

Thanks for any help.

Function DoTheConversion()
Dim table "Structural 2005" As rs

DoCmd.RunSQL "update rs set [Active] = [Amount]* 8.35 * [Formulation] * 0.01 where [Units] = 'GAL'"

DoCmd.RunSQL "update rs set [Active] = [Amount]/16 * [Formulation] * 0.01 where [Units] = 'OZ'"

DoCmd.RunSQL "update rs set [Active] = [Amount] * [Formulation] * 0.01 where [Units] = 'LBS'"

End Function

 
Like this ?
Function DoTheConversion()
Dim myTable As string
myTable = "[Structural 2005]"

DoCmd.RunSQL "update " & rs " set [Active] = [Amount]* 8.35 * [Formulation] * 0.01 where [Units] = 'GAL'"

DoCmd.RunSQL "update " & rs " set [Active] = [Amount]/16 * [Formulation] * 0.01 where [Units] = 'OZ'"

DoCmd.RunSQL "update " & rs " set [Active] = [Amount] * [Formulation] * 0.01 where [Units] = 'LBS'"

End Function

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I think that this is what you're trying to do
Code:
Function DoTheConversion()
Const table As string = "[Structural 2005]"

DoCmd.RunSQL "update " & table & " set [Active] = [Amount]* 8.35 * [Formulation] * 0.01 where [Units] = 'GAL'"

DoCmd.RunSQL "update " & table & " set [Active] = [Amount]/16 * [Formulation] * 0.01 where [Units] = 'OZ'"

DoCmd.RunSQL "update " & table & " set [Active] = [Amount] * [Formulation] * 0.01 where [Units] = 'LBS'"

End Function

There are no recordsets involved in an UPDATE ststement.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top