View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Tim Williams Tim Williams is offline
external usenet poster
 
Posts: 1,588
Default Help with Access Database Query!!

What's the text of the error message?

--
Tim Williams
Palo Alto, CA


"Vince" wrote in message
...
Jim,
I made the change below, I still get the error when the rs.open is

executed.
The error I get is -2147217900. I don't know if that error code helps or
not. My code reads as follows:
rs.Open "Select *FROM tblDoctorBladesQuery WHERE
tblDoctorBladesQuery.MachineLocation = " & cboMachineLocation.Value , cn,
adOpenDynamic, adLockOptimistic, adCmdText.

Your help with this is greatly appreciated.

"Jim Thomlinson" wrote:

tblDoctorBladesQuery.MachineLocation = " &
cboMachineLocation.Value ,cn,adOpenDynamic,adLockOptimistic,adCmdText

Try this. Your cbo value was just a string ("cboMachineLocation.Value"),

not
the value form the cbo...

HTH

"Vince" wrote:


The code in example #1 works fine, but I am trying to figure out what

is
wrong with the code in example #2. I get an error when I try to open

the
recordset. I am trying to pass a value from a combo box to the query

in
example #2 so the user can select different values. I can't get it to

work,
I am looking for help.

example #1

Dim sSql as String
Dim i as Integer
Dim cn as ADODB.Connection, rs as ADODB.Recordset, r AS Long, c ASLong

Set cn = New ADODB.Connection
cn.Open "Provider=Microsoft.Jet.Oledb.4.0; " & _
"Data Source=C:\DoctorBlades.mdb;"

Set rs = New ADODB.Recordset
rs.Open "tblDoctorBladesQuery",cn,adOpenDynamic,adLockOpti mistic


example #2

Dim sSql as String
Dim i as Integer
Dim cn as ADODB.Connection, rs as ADODB.Recordset, r AS Long, c ASLong

Set cn = New ADODB.Connection
cn.Open "Provider=Microsoft.Jet.Oledb.4.0; " & _
"Data Source=C:\DoctorBlades.mdb;"

Set rs = New ADODB.Recordset
rs.Open "Select * FROM tblDoctorBladesQuery WHERE
tblDoctorBladesQuery.MachineLocation =
cboMachineLocation.Value",cn,adOpenDynamic,adLockO ptimistic,adCmdText