Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I can't use an SQL INSERT statement

Status
Not open for further replies.

carlosweiss

Programmer
Sep 15, 2005
15
AR
Hi,

I'm also new to VB and I'm used to working with SQL statements. From a previous thread I read that the way to use an Insert SQL looks like this:

Code:
  Dim dbUsers As Database
  Call Initialize_Form
  Dim rsUSER_INFO As Recordset
  Set dbUsers = OpenDatabase("c:\PESCE\PESCE.mdb")
  sqlaction = "INSERT INTO table1 (field1) VALUES (1)"      
  dbUsers.Execute sqlaction
  dbUsers.Close

I tried to use that code but I get a syntax error at the very beginning: "the defined type has not been defined by the user", pointing to the "Database" reserved word.

I'm using VB 6.0, and this code is within a form. I have a Data control with which I could use an SQL SELECT statement, but now I want to use an INSERT that is different to the recordSource columns defined there. What am I forgetting?

Thanks,

Carlos
 
Carlos,

Your program requires an object library reference.

Go to Project -- References then scroll down and tick the "Microsoft DAO x.x object library"

Trevor
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top