Hi all,
I am having some trouble with my VBA code attached below. It is coming up with a runtime error (3464 - data type mismatch). I am unsure of what I have done wrong and any assistance would be greatly appreciated.
Private Sub cmdAdd_Click()
Dim strInsert As String
If IsNull(Me.txtPolicyNum) Or IsNull(Me.txtinception) Or IsNull(Me.txtExpiryDAte) Or IsNull(Me.txtAccountNumber) Then
MsgBox "Please Complete Policy Details"
Else
strInsert = "insert into VehicleRecords (Vehicle_is_registered, State_of_Registration, Registration_Number, State_of_base_operations, Suburb, Postcode, CoverType, Standard_excess, Imposed_excess, Total_variable_excess, No_claim_bonus_entitlement, claim_bonus_verified, protect_noclaim_bonus, Build_Year, Class, Make, Model, Redbook_code, Full_description, Vehicle_value, Standard_accessories, yn_nonstandard_accessories, yn_vehicle_mods, Value_NSA_Mods, NS_accessories, Policy_record, Inception_Date, Expiry_Date, Account_Number, Premium, Fire_Levy, GST, Stamp_Duty, Adj_Percentage, Premium_Subtotal, Premium_Adjustment_Amount, Commission_Amount, Commission_GST, Insured_Name, Postal_Address, Business_Occupation, Interested_Party, Nature_of_Interest)" & _
"values( '" & Me.cboVehicleRegistered & "','" & Me.cboStateofRego & "','" & Me.txtRegoNumber & "','" & Me.cboBaseOps & "','" & Me.txtBaseOperations & "','" & Me.txtPostcode & "','" & Me.cboCoverType & "','" & Me.txtStandardExcess & "','" & Me.txtImposedExcess & "','" & Me.txtTotalVariableExcess & "','" & Me.cboNoClaimBonusEntit & "','" & Me.cboVerifynoClaimBonus & "','" & Me.cboProtectNoClaim & "','" & Me.txtBuildYear & "','" & Me.cboClass & "','" & Me.cboMake & "','" & Me.cboModel & "','" & Me.txtRedbook & "','" & Me.txtFulldescription & "','" & Me.txtVehicleValue & "','" & Me.txtStandardaccessories & "','" & Me.cboNSAccessories & "','" & Me.cboMods & "','" & Me.txtModsValues & "','" & Me.txtnonstandardaccessories & "','" & Me.txtPolicyNum & "','" & Me.txtinception & "','" & Me.txtExpiryDAte & "','" & Me.txtAccountNumber & "','" & Me.txtPremium & "','" & Me.txtFireLevy & "','" & Me.txtGST & "','" & Me.txtStampDuty & "','" & Me.txtAdjPerc & "','" & Me.txtPremAdjAmount & "','" & _
Me.txtCommissionAmount & "','" & Me.txtCommissionGST & "','" & Me.txtSubtotal & "','" & Me.txtInsuredName & "','" & Me.txtPostalAddress & "','" & Me.txtBusiness & "','" & Me.txtParty & "','" & Me.txtInterest & "')"
DoCmd.SetWarnings False
CurrentDb.Execute strInsert, dbFailOnError
DoCmd.SetWarnings True
MsgBox "Vehicle added successfully"
'add data to table
End If
'refresh data from list on form
frmVehicleRecordsSubform.Form.Requery
End Sub
I am having some trouble with my VBA code attached below. It is coming up with a runtime error (3464 - data type mismatch). I am unsure of what I have done wrong and any assistance would be greatly appreciated.
Private Sub cmdAdd_Click()
Dim strInsert As String
If IsNull(Me.txtPolicyNum) Or IsNull(Me.txtinception) Or IsNull(Me.txtExpiryDAte) Or IsNull(Me.txtAccountNumber) Then
MsgBox "Please Complete Policy Details"
Else
strInsert = "insert into VehicleRecords (Vehicle_is_registered, State_of_Registration, Registration_Number, State_of_base_operations, Suburb, Postcode, CoverType, Standard_excess, Imposed_excess, Total_variable_excess, No_claim_bonus_entitlement, claim_bonus_verified, protect_noclaim_bonus, Build_Year, Class, Make, Model, Redbook_code, Full_description, Vehicle_value, Standard_accessories, yn_nonstandard_accessories, yn_vehicle_mods, Value_NSA_Mods, NS_accessories, Policy_record, Inception_Date, Expiry_Date, Account_Number, Premium, Fire_Levy, GST, Stamp_Duty, Adj_Percentage, Premium_Subtotal, Premium_Adjustment_Amount, Commission_Amount, Commission_GST, Insured_Name, Postal_Address, Business_Occupation, Interested_Party, Nature_of_Interest)" & _
"values( '" & Me.cboVehicleRegistered & "','" & Me.cboStateofRego & "','" & Me.txtRegoNumber & "','" & Me.cboBaseOps & "','" & Me.txtBaseOperations & "','" & Me.txtPostcode & "','" & Me.cboCoverType & "','" & Me.txtStandardExcess & "','" & Me.txtImposedExcess & "','" & Me.txtTotalVariableExcess & "','" & Me.cboNoClaimBonusEntit & "','" & Me.cboVerifynoClaimBonus & "','" & Me.cboProtectNoClaim & "','" & Me.txtBuildYear & "','" & Me.cboClass & "','" & Me.cboMake & "','" & Me.cboModel & "','" & Me.txtRedbook & "','" & Me.txtFulldescription & "','" & Me.txtVehicleValue & "','" & Me.txtStandardaccessories & "','" & Me.cboNSAccessories & "','" & Me.cboMods & "','" & Me.txtModsValues & "','" & Me.txtnonstandardaccessories & "','" & Me.txtPolicyNum & "','" & Me.txtinception & "','" & Me.txtExpiryDAte & "','" & Me.txtAccountNumber & "','" & Me.txtPremium & "','" & Me.txtFireLevy & "','" & Me.txtGST & "','" & Me.txtStampDuty & "','" & Me.txtAdjPerc & "','" & Me.txtPremAdjAmount & "','" & _
Me.txtCommissionAmount & "','" & Me.txtCommissionGST & "','" & Me.txtSubtotal & "','" & Me.txtInsuredName & "','" & Me.txtPostalAddress & "','" & Me.txtBusiness & "','" & Me.txtParty & "','" & Me.txtInterest & "')"
DoCmd.SetWarnings False
CurrentDb.Execute strInsert, dbFailOnError
DoCmd.SetWarnings True
MsgBox "Vehicle added successfully"
'add data to table
End If
'refresh data from list on form
frmVehicleRecordsSubform.Form.Requery
End Sub