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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
Leigh PurvisDatabase DeveloperCommented:
Usual culprit - my guess would be

Dim RS As DAO.Recordset
The 7 Worst Nightmares of a Sysadmin

Fear not! To defend your business’ IT systems we’re going to shine a light on the seven most sinister terrors that haunt sysadmins. That way you can be sure there’s nothing in your stack waiting to go bump in the night.

Leigh PurvisDatabase DeveloperCommented:
(lol without having seen the line it occurs on - but still my guess.  Do you have the DAO library referenced?)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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 ;-)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.