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

Help please with .AddNew method 1

Status
Not open for further replies.

LD1010

Technical User
Dec 6, 2001
78
US
I'm trying to automatically add a new record to a table based on the values of a number of combo box on a form called frmContentsStorageEntry. Following is the code I have so far but when it runs I get an error "Object variable or With block variable not set (Error 91)"

Private Sub SharedStart_AfterUpdate()

Dim db As Database
Dim rec As DAO.Recordset

Set rec = db.OpenRecordset("tblContentsStorage", dbOpenDynaset)
With rec
.AddNew
!FileNumber = Me.CboSharedFileNumber
!StorageVendorID = Me.cboStrorageVendorID
!StorageStarted = Me.SharedStart
!SharedStorage = Me.SharedStorage
!SharedFileNumber = Me.FileNumber
!SharedStart = Me.SharedStart
.Update
End With

End Sub

I'm new at writing code, any help would be much apprciated.
 
You have not assigned anything to db.

Set db=CurrentDB
 
Thanks Remou, that did the trick, work great.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top