![]() |
Syntax problem
Hi all!
I am using the following code in order to import records from access table. cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=C:\Documents and Settings\Eli\My Documents\ETV_Cells.mdb" rst.Open "SELECT DISTINCT [Printing_Date] FROM " & strTableName & " ORDER BY [Printing_Date] ;", cnn, adOpenStatic rst.MoveFirst With Me.cboViewPrntDate .Clear Do .AddItem rst![Printing_Date] rst.MoveNext Loop Until rst.EOF End With My problem is with changing the field name ([Printing_Date]) into a string in order to use this code for more then one field instead of duplicating the code for each field. I tried: strField = "Printing_Date" strField = "[Printing_Date]" but i got error messages that was pointed to ".AddItem rst![Printing_Date]" line. Thanks in advance Eli |
Syntax problem
rst.Open "SELECT DISTINCT [Printing_Date] FROM " & strTableName & "
ORDER BY [" & printDateVariable *& "] ;", cnn, adOpenStatic HTH Bob "???" wrote in message ... Hi all! I am using the following code in order to import records from access table. cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=C:\Documents and Settings\Eli\My Documents\ETV_Cells.mdb" rst.Open "SELECT DISTINCT [Printing_Date] FROM " & strTableName & " ORDER BY [Printing_Date] ;", cnn, adOpenStatic rst.MoveFirst With Me.cboViewPrntDate .Clear Do .AddItem rst![Printing_Date] rst.MoveNext Loop Until rst.EOF End With My problem is with changing the field name ([Printing_Date]) into a string in order to use this code for more then one field instead of duplicating the code for each field. I tried: strField = "Printing_Date" strField = "[Printing_Date]" but i got error messages that was pointed to ".AddItem rst![Printing_Date]" line. Thanks in advance Eli |
Syntax problem
Use the Ampersand (&) for strField just like you did for strTableName.
Mike F "???" wrote in message ... Hi all! I am using the following code in order to import records from access table. cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=C:\Documents and Settings\Eli\My Documents\ETV_Cells.mdb" rst.Open "SELECT DISTINCT [Printing_Date] FROM " & strTableName & " ORDER BY [Printing_Date] ;", cnn, adOpenStatic rst.MoveFirst With Me.cboViewPrntDate .Clear Do .AddItem rst![Printing_Date] rst.MoveNext Loop Until rst.EOF End With My problem is with changing the field name ([Printing_Date]) into a string in order to use this code for more then one field instead of duplicating the code for each field. I tried: strField = "Printing_Date" strField = "[Printing_Date]" but i got error messages that was pointed to ".AddItem rst![Printing_Date]" line. Thanks in advance Eli |
All times are GMT +1. The time now is 12:09 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com