Addnew Record

mboe

Registered User.
Local time
Today, 19:29
Joined
Dec 27, 2000
Messages
51
I am trying to add a new record to a table with the following code. I keep getting the following error.

Run time error 3001

Invalid Argument

All the other posts I found look just like mine so I can't figure out why it's not working. Since the code works with the currentdb I didn't think it would matter that my tables are linked tables. Just in case I imported the tables and got the same error. Here's my code and any help would be great.

Private Sub cmdAddSkill_Click()
Dim MyRecords As Recordset

Set MyRecords = CurrentDb.OpenRecordset("tblCharacterSkills", dbOpenDynaset)

With MyRecords
.AddNew
!CharID = Me!txtCharIDtmp
!SAreaID = Me!txtSAreaIDtmp
!SubAreas = Me!chkSubareastmp
!Attributes = Me!txtAttributestmp
!Type = Me!txttypetmp
.Update
End With
MyRecords.Close

End Sub
 
If you are using the code in Access 2000 or 2002 ... then the problem is ... you are using DAO methods in the app.

You need to alter the following line:
Dim MyRecords As Recordset

Change it to:

Dim MyRecords As DAO.Recordset

Also you need to enable the "Microsoft DAO 3.6 Library" in the app.
To do this .... open any module (or a new empty module) in design view. Choose Tools/References in the VAB code window. Scroll down the list and locate the library I have given and place a check in the checkbox to the left of the library to enable it. Close the dialog box and your code should now run without the error you were receiving.

HTH
RDH
 

Users who are viewing this thread

Back
Top Bottom