Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 67
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 834
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 206
Default 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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
ADO syntax problem אלי Excel Programming 2 January 5th 10 05:21 AM
Problem with Syntax? MurrayBarn Excel Worksheet Functions 8 June 12th 09 01:45 PM
Help Please: Syntax Problem Oblivious Excel Programming 3 June 6th 06 03:00 PM
Syntax problem unknowndevice[_4_] Excel Programming 4 August 26th 05 10:57 PM
Another Syntax Problem Sharlene England Excel Programming 2 December 2nd 03 10:04 PM


All times are GMT +1. The time now is 11:13 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright 2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"