Hi there everyone, I am fairly new to access this is my first major project and am running into problems with a sub that I am using... here are the symptoms if I open up and older version of my DB and cut and paste this sub into it, it works for a little while and then after either shutting it down and restarting or just a random amount of time it stops working and gives me the error
Run-Time Error '2109':
There is no field named 'CAB' in the current record.
I am unsure of why it is doing this obviously I am not changing anything in my tables so the field is still there.. here is my code I appreciate anyones help on this matter...
Code:
Private Sub CAB_KeyDown(KeyCode As Integer, Shift As Integer)
Dim strNewCAB As String
Dim strOldCAB As String
If EditCAB = False Then
strOldCAB = CAB.Value
If MsgBox("Are You Sure You Would Like To Change This Cab number?", _
vbYesNo + vbQuestion + vbDefaultButton2, _
"Please Confirm:") = vbYes Then
Me!CAB.Locked = False
EditCAB = True
strNewCAB = InputBox("What is the new cab number?", "New Cab number")
If strNewCAB = "" Or strNewCAB = Empty Then
MsgBox "No Input Provided", vbInformation, "Required Data"
CAB.Value = strOldCAB
Me!CAB.Locked = True
EditCAB = False
DoCmd.RunCommand acCmdSaveRecord
CAB.SetFocus
Exit Sub
End If
If strNewCAB < 1000 Then
Dim strSearch As String
DoCmd.ShowAllRecords
DoCmd.GoToControl ("CAB")
DoCmd.FindRecord strNewCAB
CAB.SetFocus
strSearch = CAB.Text
If strSearch = strNewCAB Then
DoCmd.ShowAllRecords
DoCmd.GoToControl ("CAB")
DoCmd.FindRecord strOldCAB
CAB.SetFocus
MsgBox "" & strSearch & " Is Taken - Please Try Again.", _
, "Important Information"
Exit Sub
Else
CAB.SetFocus
txtoldcab.Visible = True
txtoldcab.SetFocus
txtoldcab.Locked = False
txtoldcab.Value = strOldCAB
txtoldcab.Locked = True
CAB.SetFocus
txtoldcab.Visible = False
CAB.Value = strNewCAB
CAB.Locked = True
EditCAB = False
DoCmd.RunCommand acCmdSaveRecord
MsgBox "Cab #" & strOldCAB & " Has Been Changed To Cab #" & strNewCAB & "", _
, "Important Information"
End If
Else
MsgBox "Sorry, This Cab Number Is Incorrect", _
vbOKOnly, "Important Information"
CAB.Value = strOldCAB
Me!CAB.Locked = True
EditCAB = False
DoCmd.RunCommand acCmdSaveRecord
CAB.SetFocus
Exit Sub
End If
Else
CAB.SetFocus
CAB.Value = strOldCAB
Me!CAB.Locked = True
EditCAB = False
End If
End If
End Sub