Hello,
I'm trying to add a new record to a different database than I'm in when a button is pushed. The following code is this:
The first field in the updated table ("Chemistry") is an Autonumber field, which will populate the next correct number, and I want the next two fields ("Xrf #" & "Project #") to fill in as specified. However the program won't create a new record in the database. I put in ".Movefirst" and then msgboxed the contents to see if it was actually finding the recorset, and it was, so the pathway is correct. I must be missing something...
Any help is greatly appreciated.
I'm trying to add a new record to a different database than I'm in when a button is pushed. The following code is this:
Code:
Dim db As database
Dim rs As Recordset
Set db = OpenDatabase("P:\BU Regeneration\XRF Laboratory\chemistry.mdb")
Set rs = db.OpenRecordset("chemistry", dbOpenDynaset)
With rs
.AddNew
.Fields("XRF #") = "99999"
.Fields("Project #") = "9999"
.Update
.Close
End With
MsgBox "Done!"
Exit_this:
Set rs = Nothing
Set db = Nothing
Exit Sub
The first field in the updated table ("Chemistry") is an Autonumber field, which will populate the next correct number, and I want the next two fields ("Xrf #" & "Project #") to fill in as specified. However the program won't create a new record in the database. I put in ".Movefirst" and then msgboxed the contents to see if it was actually finding the recorset, and it was, so the pathway is correct. I must be missing something...
Any help is greatly appreciated.