Reputation: 68
I am very new to VBA. I managed to get my head around Powershell and have worked in SQL for years. But this is the most frustrating language!
I have a Form where a user specifies a source from a combo box.
I then have a macro which should lookup a table and a query based on what the use puts in.
So far i have the table name I want in a variable. I want to pass this to docmd.opentable
But have not figured it out :(
Dim str_DeltaTable As String
str_DeltaTable = DLookup("Table_Delta", "QC_Report_List", "Source = '" & Forms!Main_Form!Source_ComboBox.Text & "'")
DoCmd.OpenTable "str_DeltaTable" 'Some help here would be ace
Thanks from a newb
Rich
Upvotes: 1
Views: 3425
Reputation: 2059
Just use the DoCmd.OpenTable str_DeltaTable
without the quotes to pass the variable's value, not its literal properly.
Also, your use of .Text
is probably going to cause problems because text boxes in Access only have .Text property while they have the focus (contrary to many other systems). Instead use the .Value
property, which is always available. It is also the default property, so you can use Forms!Main_Form!Source_ComboBox.Value
or just Forms!Main_Form!Source_ComboBox
.
Upvotes: 1