• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1116
  • Last Modified:

OpenRecordset AddNew

Private Sub btnADD_Click()

Dim RS As Recordset

Hi

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.
Thanks

Set RS = CurrentDb.OpenRecordset("T12_ReceivedGoods")

With RS
.AddNew

!PurchaseOrderID = Me!POID
!LineNo = Me!LineNo
!DeliveryNo = Me!AdvNoteNumber
!QtyReceived = Me!Rcd
.Update
End With
RS.Close

End Sub
0
hutchisonj
Asked:
hutchisonj
1 Solution
 
peter57rCommented:
Hi hutchisonj,
> However, I receive a run time error 13 'Type Mismatch'
where?

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

the above line of code is highlighted in yellow
0
 
Leigh PurvisDatabase DeveloperCommented:
Usual culprit - my guess would be

Dim RS As DAO.Recordset
0
Get quick recovery of individual SharePoint items

Free tool – Veeam Explorer for Microsoft SharePoint, enables fast, easy restores of SharePoint sites, documents, libraries and lists — all with no agents to manage and no additional licenses to buy.

 
Leigh PurvisDatabase DeveloperCommented:
(lol without having seen the line it occurs on - but still my guess.  Do you have the DAO library referenced?)
0
 
hutchisonjAuthor Commented:
thanks that has stopped the error message, but the record is not inserting into the table (and giving no error message?)
0
 
hutchisonjAuthor Commented:
i do have dao library referenced
0
 
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?
0
 
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.
0
 
jerryb30Commented:
why the ! for me?
shouldn't it be me.whatever?
0
 
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 ;-)
http://www.experts-exchange.com/Databases/MS_Access/Q_21652154.html
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now