I can't figure out why this error keeps popping out when I run my code. It always says that frmImmunizationRecord cannot be "found" by VB.
Function decreaseStockOnHand()
Dim stock As Integer
Dim computedStock As Integer
Dim strSQL As String
Dim vaccineCode As String
If [Forms]![frmImmunizationRecord]![Vaccine] Is Not Null And [Forms]![frmImmunizationRecord]![p1BrandName] Is Not Null Then <<<****ERROR IN THIS LINE****
DoCmd.SetWarnings False
vaccineCode = DLookup("[VaccineID]", "tblVaccine", "[VaccineName] =" & [Forms]![frmImmunizationRecord]![Vaccine] And "[BrandName]=" & [Forms]![frmImmunizationRecord]![p1BrandName])
stock = DLookup("[StockOnHand]", "tblVaccine", "[VaccineID] = vaccineCode"![Wink ;) ;)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
computedStock = stock - 1
strSQL = "UPDATE tblVaccine SET StockOnHand = " & computedStock & " WHERE VaccineID = vaccineCode"
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
End If
End Function
How should I remedy this? Is my syntax correct? The If-statement is supposed to check that the 2 fields (vaccine and brand name) in frmImmunizationRecord are not null, and if so, continue on with the computation.
Thank you! =)
Function decreaseStockOnHand()
Dim stock As Integer
Dim computedStock As Integer
Dim strSQL As String
Dim vaccineCode As String
If [Forms]![frmImmunizationRecord]![Vaccine] Is Not Null And [Forms]![frmImmunizationRecord]![p1BrandName] Is Not Null Then <<<****ERROR IN THIS LINE****
DoCmd.SetWarnings False
vaccineCode = DLookup("[VaccineID]", "tblVaccine", "[VaccineName] =" & [Forms]![frmImmunizationRecord]![Vaccine] And "[BrandName]=" & [Forms]![frmImmunizationRecord]![p1BrandName])
stock = DLookup("[StockOnHand]", "tblVaccine", "[VaccineID] = vaccineCode"
computedStock = stock - 1
strSQL = "UPDATE tblVaccine SET StockOnHand = " & computedStock & " WHERE VaccineID = vaccineCode"
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
End If
End Function
How should I remedy this? Is my syntax correct? The If-statement is supposed to check that the 2 fields (vaccine and brand name) in frmImmunizationRecord are not null, and if so, continue on with the computation.
Thank you! =)