dimanche 19 avril 2015

VBA Variable/Method missing


Private Sub cmdProcessInvoice_Click()
'add data to table
CurrentDb.Execute "INSERT INTO SalesSummary(InvoiceNumber, InvoiceDate, TotalQuantitySold, TotalAmount, EmployeeNumber) " & _
" VALUES ('" & Me.txtInvoice & "','" & Date & "','" & Me.txtTotalQuantitySold & "','" & Me.txtITotalAmount & "','" & Me.txtEmployeeI & "')"
'refresh data on list of form
SalesSummarySub.Form.Requery

Me.txtPI1 = DLookup("UnitPrice", "Products", "Username='" & Me.txtI1.Value & "'") * Me.txtQI1
Me.txtPI2 = DLookup("UnitPrice", "Products", "Username='" & Me.txtI2.Value & "'") * Me.txtQI2
Me.txtPI3 = DLookup("UnitPrice", "Products", "Username='" & Me.txtI3.Value & "'") * Me.txtQI3
Me.txtPI4 = DLookup("UnitPrice", "Products", "Username='" & Me.txtI4.Value & "'") * Me.txtQI4
Me.txtPI5 = DLookup("UnitPrice", "Products", "Username='" & Me.txtI5.Value & "'") * Me.txtQI5

Me.txtITotalAmount = Me.txtPI1 + Me.txtPI2 + Me.txtPI3 + Me.txtPI4 + Me.txtPI5

Me.txtITotalQuantitySold = Me.txtQI1 + Me.txtQI2 + Me.txtQI3 + Me.txtQI4 + Me.txtQI5

End Sub


My VBA code above is suppose to store and record the values that were input in the form, but after the button has been clicked, there would be a compile error wherein a method or data member is not found.


I'm pretty sure the name of the values I placed above are correct and are the same with the labels I placed for the text boxes and buttons.


How do I solve this?


Aucun commentaire:

Enregistrer un commentaire