From: אלי on 4 Jan 2010 08:23 Hi! I am using the following code to query access table. the code works fine. My problem is how to name the field name ([Cell]) as a string, in order to use this query as a dynamic query. I tried many things but nothing succeeded. Thanks for your help! Dim cnn As New ADODB.Connection Dim rst As New ADODB.Recordset cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=C:\Documents and Settings\Eli\My Documents\ETV_Cells.mdb" rst.Open "SELECT * FROM CellTable ;", cnn, adOpenStatic rst.MoveFirst strCellCode = rst![Cell] rst.Close cnn.Close Set rst = Nothing Set cnn = Nothing Eli
From: JP Ronse on 4 Jan 2010 09:53 Eli, Declare a variable varCellCode as variant & varCellCode = rst. Wkr, JP "???" <@discussions.microsoft.com> wrote in message news:A5685E63-43E1-4081-AEF4-FAB5801EAC64(a)microsoft.com... > Hi! > > I am using the following code to query access table. the code works fine. > My > problem is how to name the field name ([Cell]) as a string, in order to > use > this query as a dynamic query. I tried many things but nothing succeeded. > > Thanks for your help! > > Dim cnn As New ADODB.Connection > Dim rst As New ADODB.Recordset > cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=C:\Documents > and > Settings\Eli\My Documents\ETV_Cells.mdb" > rst.Open "SELECT * FROM CellTable ;", cnn, adOpenStatic > rst.MoveFirst > strCellCode = rst![Cell] > > rst.Close > cnn.Close > Set rst = Nothing > Set cnn = Nothing > > > Eli
From: Tim Williams on 5 Jan 2010 00:21 strCellCode = rst.Fields("Cell").Value Tim "???" <@discussions.microsoft.com> wrote in message news:A5685E63-43E1-4081-AEF4-FAB5801EAC64(a)microsoft.com... > Hi! > > I am using the following code to query access table. the code works fine. > My > problem is how to name the field name ([Cell]) as a string, in order to > use > this query as a dynamic query. I tried many things but nothing succeeded. > > Thanks for your help! > > Dim cnn As New ADODB.Connection > Dim rst As New ADODB.Recordset > cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=C:\Documents > and > Settings\Eli\My Documents\ETV_Cells.mdb" > rst.Open "SELECT * FROM CellTable ;", cnn, adOpenStatic > rst.MoveFirst > strCellCode = rst![Cell] > > rst.Close > cnn.Close > Set rst = Nothing > Set cnn = Nothing > > > Eli
|
Pages: 1 Prev: using find in excel from C# code Next: Workbooks.OpenText Method / FieldInfo |