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

Type Mismatch On Opening A Recordset?

Status
Not open for further replies.

Fozzy666

Programmer
Apr 2, 2003
4
GB

Can Any one shed some light on this problem i have.

I have a database with a table called "Main". I am trying to copy three filtered bit of information from a form to create a new record but i keep getting this error:

Run-Time Error '13'

Type Mismatch

My coding is:

Dim txtProj As String, txtArea As String, txtSect As String
Dim dbs As Database, rst As Recordset

txtProj = Me.Project
txtArea = me.Area
txtSect = me.Section1

Set dbs = currentdb

Set rst = dbs.Openrecordset("Main")

rst.AddNew
rst.Fields("Project") = txtProj
rst.Fields("Area") = txtArea
rst.Fields("Section") = txtSect
rst.Update
rst.Close

Set dbs = Nothing


The error comes from Set rst= dbs.Recordset("Main")

(Me.Project is a text field)
(Me.Area is a number field)
(Me.Section1 is a number field)

Can anyone see any errors in my coding or suggest any solutions?


 
Hi,

Try this since u are updating your table!main of the database.

Set rst = dbs.Openrecordset("Main",dbOpentable)

rest looks ok

Hope it works.
 

Cheers for your suggestion JLeo but it still doesn't work. Are there any other ways around using the recordset to copy information off the form to create a new record?
 
Since you are using Dao try

dim dbs as dao.database
dim rsr as dao.recordset
 
Oops, missed that out. :)
Anyway Stalo's suggestion should work. Experienced that error before too. Good Luck.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top