PC Review


Reply
Thread Tools Rate Thread

ADO syntax problem

 
 
אלי
Guest
Posts: n/a
 
      4th Jan 2010
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
 
Reply With Quote
 
 
 
 
JP Ronse
Guest
Posts: n/a
 
      4th Jan 2010
Eli,

Declare a variable varCellCode as variant & varCellCode = rst.

Wkr,

JP


"???" <@discussions.microsoft.com> wrote in message
news:A5685E63-43E1-4081-AEF4-(E-Mail Removed)...
> 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



 
Reply With Quote
 
Tim Williams
Guest
Posts: n/a
 
      5th Jan 2010
strCellCode = rst.Fields("Cell").Value

Tim



"???" <@discussions.microsoft.com> wrote in message
news:A5685E63-43E1-4081-AEF4-(E-Mail Removed)...
> 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



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with Syntax? MurrayBarn Microsoft Excel Worksheet Functions 8 12th Jun 2009 01:45 PM
For-each syntax problem excelnut1954 Microsoft Excel Programming 5 10th May 2007 03:09 PM
syntax problem with gpresult - and problem with Group Pol in gener =?Utf-8?B?Sm9yZGFu?= Microsoft Windows 2000 Group Policy 1 12th Apr 2007 08:32 PM
Problem with syntax..HELP =?Utf-8?B?VGltOjouLg==?= Microsoft ASP .NET 3 19th May 2004 06:31 PM
syntax problem David Hunt Microsoft Access VBA Modules 3 17th Oct 2003 06:20 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:37 AM.