Problem running a query

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hello!

I'm trying to run the following query, but I get an error message:

The code:

Dim oDataBase As DAO.Database
Set oDataBase = OpenDatabase("C:\Program Files\Microsoft Visual
Studio\VB98\NWIND.MDB")

sql = sql & "SELECT Customers.Customers_ID, Customers.Company_ID,
Customers.C_Email, Customers.C_FName, Customers.C_LName "
sql = sql & "FROM Customers "
sql = sql & "WHERE (((Customers.Company_ID)=" & num & ")) "
sql = sql & "ORDER BY Customers.C_LName;"

Dim qdf As DAO.QueryDef
Set qdf = oDataBase.CreateQueryDef("My sql", sql)


The error message:
object variable or with block variable not set

How can I fix the problem?

thanks,
Yonina.
 
Am Tue, 6 Dec 2005 06:25:03 -0800 schrieb קובץ:

Yonina, if that´s all the code then "oDataBase" is nothing. That is the
OpenDatabase function doesn´t work.

I´m not sure as I didn´t use DAO for about 10 years. Maybe the DB doesn´t
exist or any paramater is missing. A look into the DAO help file for
OpenDatabase should help you.
 
right! it didn't work so I changed its name to oDataBase2 and now it works.
Why did it stop working? It worked before..
 
Back
Top