Hello,
In ACCESS 2003, I have a combox with a drop-down menu where I can select a name from a table where one of the fields is FactorName. I'm selecting a name from this field.
I have another table called FactorsCol1 which has 4 fields (including the same FactorName):
ClassName, FactorName, FactorIndex, ClassID
I want to extract a FactorIndex from this table based on information obtained after the choice in my drop down menu. Which means if I select a name say "ABC" I want to exctract the FactorIndex say "005", which is associated with this name. But here is the problem:
I use the following code:
MyVar is the name that I get from the field FactorName in my first table. It is always correct because I'm checking it with debug.print. For an unknown reason I get always an empty TestTable1. If however I replace the MyVar directly with the name (say ABC, see the code before) then the SQL is executed and I get the corresponding FactorIndex. Is there something wrong with using variable in this statment?
In ACCESS 2003, I have a combox with a drop-down menu where I can select a name from a table where one of the fields is FactorName. I'm selecting a name from this field.
I have another table called FactorsCol1 which has 4 fields (including the same FactorName):
ClassName, FactorName, FactorIndex, ClassID
I want to extract a FactorIndex from this table based on information obtained after the choice in my drop down menu. Which means if I select a name say "ABC" I want to exctract the FactorIndex say "005", which is associated with this name. But here is the problem:
I use the following code:
Code:
MyVar = Me.FactorSelector1 Debug.Print MyVar DoCmd.RunSQL " SELECT FactorsCol1.FactorIndex, FactorsCol1.FactorName INTO TestTable1 FROM FactorsCol1 WHERE (([FactorsCol1].[FactorName]) = ' & MyVar & ') "
Code:
DoCmd.RunSQL " SELECT FactorsCol1.FactorIndex, FactorsCol1.FactorName INTO TestTable1 FROM FactorsCol1 WHERE (([FactorsCol1].[FactorName]) = ' ABC') "
Comment