I have the follow code on a form with three unbound fields but when I try to save I get
The database has been placed in a state by user 'Admin' on machine 'hp' that prevents it from bring opened or locked.
What am I doing wrong I copied most of this code from a sample mdb
I have not written much code before. Just learning.
Private Sub Command6_Click()
Dim err As Integer
Dim cnn1 As ADODB.Connection
Dim rstflights As ADODB.Recordset
Dim strCnn As String
'Check that all fields are filled in
If bid.Text = "" Then
err = err + 1
MsgBox "Please fill in the Bat ID!" & err
'if no errors insert data
If err < 1 Then
' Open a connection.
Set cnn1 = New ADODB.Connection
mydb = "c:\accessdev\rclog bob.mdb"
strCnn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & mydb
' Open flights table.
Set rstflights = New ADODB.Recordset
rstflights.CursorType = adOpenKeyset
rstflights.LockType = adLockOptimistic
rstflights.Open "flights", cnn1, , , adCmdTable
'get the new record data
rstflights!id = ibid
' need code for planes and battery
' Show the newly added data.
MsgBox "New flights: " & rstflights!Name & " has been successfully added"
MsgBox "An Error has occurred, please check and try again"
Private Sub Command7_Click()
bid = ""
I got it working seems I have to close access sometimes to get access not sure why but I have it adding now. Not sure why field name [ibattery id] works but not [flights.ibattery id] don't work. How does it know which table if I have the save field name in two tables. I don't right now for descriptions names I use sfdescription where s is string and f is the first letter of the tables name.
The period (.) divides an object from one of its properties. You should use the exclamation point (!) to separate the flight object from its child object battery id (as in fact you appear to have done elswhere in the script).