Skip to main content
edited tags
Link
HansUp
  • 97.3k
  • 11
  • 80
  • 139
Source Link
user1698144
  • 764
  • 4
  • 14
  • 38

SQL / Access Object Requires Error

I am intending to use the code below to insert a record into the database. However, it is throwing an object required error. I have checked and all the variables contain data.

Dim vblMealType As String
Dim vblMealQual As String


If txtMealID.ItemsSelected.Count = 0 Then

        MsgBox "Please Select a Meal Type", _
               vbOKOnly + vbInformation
Else



 MsgBox "Customer Charge Succesfull.", _
              vbOKOnly + vbInformation

Dim qdf As DAO.QueryDef

 ERROR ON THE VALUES LINE
Set qdf = dbs.CreateQueryDef("", _
        "PARAMETERS prmCustomerID Text(255), prmMealID Text(255), prmTransactionAmount Currency, prmTransactionDate Text(255);" & _
        "INSERT INTO dbo_Transactions (CustomerID, MealID, TransactionAmount, TransactionDate) " & _
        "VALUES ([prmCustomerID], [prmMealID], [prmTransactionAmount], [prmTransactionDate])")


qdf!prmCustomerID = txtCustomerID.Value
qdf!prmMealID = txtMealID.Value
qdf!prmTransactionAmount = txtCharge.Value
qdf!prmTransactionDate = Date
qdf.Execute dbFailOnError
 MsgBox "Customer Charge Succesfull.", _
              vbOKOnly + vbInformation

Set qdf = Nothing
Set dbs = Nothing

DoCmd.OpenForm "Charge Form"
DoCmd.Close acForm, Me.Name