I'm quite bamboozled.
Recently i attempted to revisit a project a started a few months ago. When testing all of my forms again, i get to this one in particular, which fails to create the new record i require it to.
Below i have a screenshot of the form & error, as well as my coding for the entire form.
I opened this project on a computer that i did not originally create the database on, however i have never had any issues prior with opening this project on different machines.
It may be also worth noting that i recently recreated a couple of tables, however i renamed them exactly the same way, and set the relationships up correctly again.
Unfortunately i did not test this form prior to recreating tables. The table this form uses specifically, was not recreated.
Any assistance would be greatly appreciated.
Code:
Option Compare DatabaseOption Explicit
Private Sub Form_Load()
DoCmd.GoToRecord , "", acNewRec
End Sub
Private Sub btnClear_Click()
Me.Undo
End Sub
Private Sub cboAccountName_AfterUpdate()
Dim SCustomerSource As String
Dim SVehicleSource As String
SCustomerSource = "SELECT [Customers].[Customer ID]," & _
" [Customers].[First Name], " & _
" [Customers].[Last Name], " & _
" [Customers].[Mobile Number], " & _
" [Customers].[Landline], " & _
" [Customers].[Fax], " & _
" [Customers].[Email Address] " & _
"From Customers " & _
"WHERE [Account Number] = " & Me.cboAccountName.Value
SVehicleSource = "SELECT [Vehicles].[Vehicle Number]," & _
" [Vehicles].[Vehicle Make], " & _
" [Vehicles].[Vehicle Model], " & _
" [Vehicles].[Rego], " & _
" [Vehicles].[Build Date], " & _
" [Vehicles].[VIN], " & _
" [Vehicles].[Required Repairs] " & _
"From Vehicles " & _
"WHERE [Account Number] = " & Me.cboAccountName.Value
Me.cboCustomerName.RowSource = SCustomerSource
Me.cboCustomerName.Requery
Me.cboVehicle.RowSource = SVehicleSource
Me.cboVehicle.Requery
End Sub
Private Sub cboCustomerName_AfterUpdate()
Me.stFirstName = Me.cboCustomerName.Column(1)
Me.stLastName = Me.cboCustomerName.Column(2)
Me.stMobilephone = Me.cboCustomerName.Column(3)
Me.stLandLine = Me.cboCustomerName.Column(4)
Me.stFax = Me.cboCustomerName.Column(5)
Me.stEmailAddress = Me.cboCustomerName.Column(6)
End Sub
Private Sub cboVehicle_AfterUpdate()
Me.stVehicleMake = Me.cboVehicle.Column(1)
Me.stVehicleModel = Me.cboVehicle.Column(2)
Me.stRego = Me.cboVehicle.Column(3)
Me.stBuildDate = Me.cboVehicle.Column(4)
Me.stVIN = Me.cboVehicle.Column(5)
Me.stRequiredRepairs = Me.cboVehicle.Column(6)
End Sub
'------------------------------------------------------------
' btnExit_Click
'
'------------------------------------------------------------
Private Sub btnExit_Click()
On Error GoTo btnExit_Click_Err
DoCmd.Close , ""
btnExit_Click_Exit:
Exit Sub
btnExit_Click_Err:
MsgBox Error$
Resume btnExit_Click_Exit
End Sub
'------------------------------------------------------------
' btnSubmit_Click
'
'------------------------------------------------------------
Private Sub btnSubmit_Click()
On Error GoTo btnSubmit_Click_Err
If IsNull(Me.cboAccountName) Or Me.cboAccountName = "" Then
MsgBox "Please select an account.", vbOKOnly, "Required Information"
Me.cboAccountName.SetFocus
Exit Sub
End If
If IsNull(Me.cboCustomerName) Or Me.cboCustomerName = "" Then
MsgBox "Please select a customer.", vbOKOnly, "Required Information"
Me.cboCustomerName.SetFocus
Exit Sub
End If
If IsNull(Me.cboVehicle) Or Me.cboVehicle = "" Then
MsgBox "Please select a Vehicle.", vbOKOnly, "Required Information"
Me.cboVehicle.SetFocus
Exit Sub
End If
If IsNull(Me.stBookingDate) Or Me.stBookingDate = "" Then
MsgBox "You need to insert a booking date!", vbOKOnly, "Required Information"
Me.stBookingDate.SetFocus
Exit Sub
End If
DoCmd.RunCommand acCmdSaveRecord
If (MacroError <> 0) Then
Beep
MsgBox MacroError.Description, vbOKOnly, ""
End If
btnSubmit_Click_Exit:
Exit Sub
btnSubmit_Click_Err:
MsgBox Error$
Resume btnSubmit_Click_Exit
End Sub
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.Dirty = True Then
Cancel = True
Me.Undo
End If
End Sub