Full Version: Saving Data To Split Database With Dao
UtterAccess Forums > Microsoft® Access > Access Forms
Quicksilver2002
I have the following code in a buttons Click event.
CODE
Private Sub btnSubmit_Click()

Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset("tblMain", dbOpenTable)
rst.AddNew
rst!Location = UCase(Me.cboLocation)
rst!DateTimeEntered = Now()
rst!PartNumber = UCase(Me.txtPartNumber)
rst!Qty = Me.txtQty
rst!RequestedBy = UCase(Me.txtRequestedBy)
rst.Update
rst.Close
Set rst = Nothing

'Clear textboxes
Me.txtDateEntered.Value = ""
Me.txtPartNumber.Value = ""
Me.txtQty.Value = ""
Me.txtRequestedBy.Value = ""

frmRequestDetails.Requery
Me.txtPartNumber.SetFocus

End Sub


I decided to split my database, and now the code doesn’t work.

Is there an easy way to edit this so that it will work with my split DB? tblMain is now in PartsMessenger_be.accdb
theDBguy
Hi. How exactly did you split your database? That code should still work if your table is linked to the backend. What does "doesn't work" mean? Were you getting any errors?
Quicksilver2002
I was thinking it should still work too. I split the database by going to Database Tools, Access Database, Split Database.

When I click on button, I get an error that says 'Run-time error '3219' Invalid operation" When I click debug its highlights the following line.
CODE
Set rst = CurrentDb.OpenRecordset("tblMain", dbOpenTable)
Quicksilver2002
Ahh....I found it. I removed the dbOpenTable and now it works.
theDBguy
Ah, maybe the dbOpenTable is causing it. I've never used that before. Try replacing it with something like dbOpenDynaset.

Edit: Oops, looks like we were posting at the same time. Glad to hear you got it sorted out.
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.