Rx_
Nothing In Moderation
- Local time
- Today, 05:19
- Joined
- Oct 22, 2009
- Messages
- 2,795
Could someone look this over and make suggestions?
Access message - You Can't save this record at this time
Do you want to close the database anyway?
but, error.number is 0
The last combo box is RegOffices -
"warning you cannot add or change a record because a related record is required in table RegOffices (its just a list of offices with a primary key, it does not get updated) I am guessing that "null" doesn't match.
Access appears to have the service packs installed.
If I open the Database, I might be able ot add 12 new records, then get a failure.
Other times, it failes on the first time (or second time, or third time ...)
The business logic code is not shown. But, if the record writes to the _be, it works perfectlly. If the record fails to create a new record on the _be then things are hosed.
And, I can't seem to recover or trap the error.
One thing I noticed is that the Autocounter counts by 2
Access message - You Can't save this record at this time
Do you want to close the database anyway?
but, error.number is 0
The last combo box is RegOffices -
"warning you cannot add or change a record because a related record is required in table RegOffices (its just a list of offices with a primary key, it does not get updated) I am guessing that "null" doesn't match.
Access appears to have the service packs installed.
If I open the Database, I might be able ot add 12 new records, then get a failure.
Other times, it failes on the first time (or second time, or third time ...)
The business logic code is not shown. But, if the record writes to the _be, it works perfectlly. If the record fails to create a new record on the _be then things are hosed.
And, I can't seem to recover or trap the error.
Code:
Form Level Variables
Dim db As dao.Database
Dim rsAddNew As dao.Recordset
AddNew Button
If Me.Dirty Then
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Me.Dirty = False
End If
Set rsAddNew = Nothing ' insures cleared second time around and on form close
Set rsAddNew = Me.Recordset
'DoCmd.GoToRecord , , acNewRec ' did not seem to work
rsAddNew.AddNew ' clears all fields in form ready for new
rsAddNew.Edit
rsAddNew!ID_Wells = Me.ID_Wells ' Hidden text box with key
rsAddNew.Update ' no error here
me.refresh
Private Sub Form_BeforeUpdate(Cancel As Integer)
'Verifies all three required fields are populated if they are change boolean variable to stop checking
' move into 4th field (has focus because we will lock down the three combo boxes)
' code in 4th field (enter) calls Form_BeforeUpdate
' now the changed boolean - run the sub Update the recordset
Sub Update the Recordset: ' Pass fail here
rsAddNew.Edit
' _be table has autocounter
' Field with Well
' three text boxes
rsAddNew!ID_Wells = Me.ID_Wells
rsAddNew!txtFedStCo = Me.cboRegulatoryType
rsAddNew!lngID_APD_Status = Me.lngID_Reg_Office
rsAddNew.Update
Me.Refresh ' the _be shows new record or The form pass / fails here
If Me.Dirty Then ' unsuccessful attempt to recover
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Debug.Print "Me dirty " & Me.Dirty ' failures are dirty
'Me.Dirty = False
Me.Refresh
End If
Code:
Debug Code - General, then after rsAddnew Edit, right before Update
The 4th time - (this time it is random) after the update - me.dirty is true
21249 ID_wells field before book mark = 3203
Before Cbo reg office 1 recordset 1
Before Cbo reg office 1 recordset 1
after update Cbo reg office 1 recordset 1
25997 ID_wells field before book mark = 3203
Before Cbo reg office 27 recordset 6
Before Cbo reg office 27 recordset 27
after update Cbo reg office 27 recordset 27
25999 ID_wells field before book mark = 3203
Before Cbo reg office 4 recordset 2
Before Cbo reg office 4 recordset 4
after update Cbo reg office 4 recordset 4
26001 ID_wells field before book mark = 3203
Before Cbo reg office 34 recordset 2
Before Cbo reg office 34 recordset 2
after update Cbo reg office 34 recordset 2
Me dirty True