OpenRecordset AddNew

Private Sub btnADD_Click()

Dim RS As Recordset


Below is my code to add a new record to table from values stored in a form (unbound)
However, I receive a run time error 13 'Type Mismatch'

Please can anyone help.

Set RS = CurrentDb.OpenRecordset("T12_ReceivedGoods")

With RS

!PurchaseOrderID = Me!POID
!LineNo = Me!LineNo
!DeliveryNo = Me!AdvNoteNumber
!QtyReceived = Me!Rcd
End With

End Sub
Who is Participating?
Leigh PurvisDatabase DeveloperCommented:
(lol without having seen the line it occurs on - but still my guess.  Do you have the DAO library referenced?)
Hi hutchisonj,
> However, I receive a run time error 13 'Type Mismatch'

hutchisonjAuthor Commented:
Set RS = CurrentDb.OpenRecordset("T12_ReceivedGoods")

the above line of code is highlighted in yellow
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Leigh PurvisDatabase DeveloperCommented:
Usual culprit - my guess would be

Dim RS As DAO.Recordset
hutchisonjAuthor Commented:
thanks that has stopped the error message, but the record is not inserting into the table (and giving no error message?)
hutchisonjAuthor Commented:
i do have dao library referenced
Leigh PurvisDatabase DeveloperCommented:
Odd that you get no error message of any kind.

Are any of the fields required?  Are they all supplied?
Any of them required to be unique - but aren't necessarily supplied as such?
Leigh PurvisDatabase DeveloperCommented:
Is the table a local native one?  Or linked to another mdb - or indeed ODBC to a different datasource?

Also, you'd normally open a recordset as
Set RS = CurrentDb.OpenRecordset("T12_ReceivedGoods",dbopendynaset)

If it's local - then a table type (the default under that scenario) should be fine too, but just something to remember if it is external.
why the ! for me?
shouldn't it be me.whatever?
Leigh PurvisDatabase DeveloperCommented:
Hi Jerry, how's you?

Either one should have been fine really.  Both would work in this scenario (assuming they're controls) - but there are indeed distinct and important differences.
There have been a few discussions here on EE alone as to which is best and when to use what.

Markus actually summed it up rather nicely last year.
(Rather then me waffle on here - I'll let him do it ;-)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.