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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dim DBS problem

Status
Not open for further replies.

judyscofield

Programmer
Sep 24, 2001
56
US
I'm in the click event of a command button. I'm trying to insert a record into a table, so I've got:

Dim dbs As Database
Set dbs = CurrentDb
Dim txtFileName as String
txtFileName = "ABC.txt"

dbs.Execute " INSERT INTO AFCARSCombine (FileName) VALUES txtFileName "

I get "User Defined Type Not Defined" with Database highlighted in the Dim dbs statement. Isn't that a standard type? What do I need to do????

Thanks

Judy Scofield
 
I tend to do it this way:

Dim dbs As DAO.Database
Set dbs = CurrentDb
Dim rst as DAO.Recordset
set rst = db.OpenRecordset("YourTable")
Dim txtFileName as String
txtFileName = "ABC.txt"

rst.AddNew
rst.Fields("AFCARSCombine") = txtFileName
rst.update

rst.close
set rst = nothing

 
When your in the VBA view, go to Tools-->References and make sure that you have Microsoft DAO 3.(something depending on your version of Access) Library

If that is checked then dodgyone's suggestion should work. But you could also do it your way, just change you DIm statement to "As DAO.Database"

Hope this helps, Kyle ::)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top