Malformed GUID error

A

Angus

I got a malformed GUID error message when running following code, which
extract data from Access database and copy to Excel spreadsheet. The bug
comes up at rs.Data.Open szSQL, szConnect about the where clause, which I
copy from MS query.


Dim objConn As ADODB.Connection
Dim rsData As ADODB.Recordset

szSQL = "SELECT db.ID, db.Market" _
& " WHERE (db.First_order_month={ts '2007-08-01 00:00:00'})"

Set rsData = New ADODB.Recordset
rsData.Open szSQL, szConnect
szConnect = "Provider=Microsoft.Jet.OLEDB.4.0; " & _
"Data Source=C:\database.mdb;"

Set rsData = Nothing
 
V

vbapro

'Where' clause with date was written incorrect, try this

Dim objConn As ADODB.Connection
Dim rsData As ADODB.Recordset

szSQL = "SELECT db.ID, db.Market WHERE (db.First_order_month=#01/08/2007#)"

Set rsData = New ADODB.Recordset
rsData.Open szSQL, szConnect
szConnect = "Provider=Microsoft.Jet.OLEDB.4.0; " & _
"Data Source=C:\database.mdb;"

Set rsData = Nothing
 
A

Angus

perfect, thanks

vbapro said:
'Where' clause with date was written incorrect, try this

Dim objConn As ADODB.Connection
Dim rsData As ADODB.Recordset

szSQL = "SELECT db.ID, db.Market WHERE (db.First_order_month=#01/08/2007#)"

Set rsData = New ADODB.Recordset
rsData.Open szSQL, szConnect
szConnect = "Provider=Microsoft.Jet.OLEDB.4.0; " & _
"Data Source=C:\database.mdb;"

Set rsData = Nothing
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top