Sorry, it is me again! =)
I am making an inventory database, and this concerns two tables- the tblVaccine (stores info about a Vaccine including its stock on hand) and the tblImmunization (records that contain the patient, vaccine, and date of vaccination). I want to automatically deduct 1 from the stock on hand of a specific vaccine when a vaccination happens. Problem is, how do I tell the database which vaccine's stock on hand to update (as there are many records of vaccines)?
My unfinished VB code is:
Function computeStockOnHand()
Dim test As String
Dim vaccine1 As String
Dim vaccine2 As String
Dim stock As Integer
Dim computedStock As Integer
Dim record As Integer
If [Forms]![frmImmunizationRecord]![Vaccine] Is Not Null And [Forms]![frmImmunizationRecord]![p1BrandName] Is Not Null Then
test = DLookup("[VaccineID]", "tblImmunization", "[Vaccine] =" & [Forms]![frmImmunizationRecord]![Vaccine] And "[p1BrandName]=" & [Forms]![frmImmunizationRecord]![p1BrandName])
stock = DLookup("[StockOnHand]", "tblVaccine", "[VaccineID]= test"![Wink ;) ;)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
computedStock = stock - 1
****computedStock is the now the updated stock hand. HOW DO I ASSIGN THIS TO THE SPECIFIC RECORD I WANT TO UPDATE?****
End Function
Again, thank you very much for your patience. Any help would be greatly appreciated. =)
I am making an inventory database, and this concerns two tables- the tblVaccine (stores info about a Vaccine including its stock on hand) and the tblImmunization (records that contain the patient, vaccine, and date of vaccination). I want to automatically deduct 1 from the stock on hand of a specific vaccine when a vaccination happens. Problem is, how do I tell the database which vaccine's stock on hand to update (as there are many records of vaccines)?
My unfinished VB code is:
Function computeStockOnHand()
Dim test As String
Dim vaccine1 As String
Dim vaccine2 As String
Dim stock As Integer
Dim computedStock As Integer
Dim record As Integer
If [Forms]![frmImmunizationRecord]![Vaccine] Is Not Null And [Forms]![frmImmunizationRecord]![p1BrandName] Is Not Null Then
test = DLookup("[VaccineID]", "tblImmunization", "[Vaccine] =" & [Forms]![frmImmunizationRecord]![Vaccine] And "[p1BrandName]=" & [Forms]![frmImmunizationRecord]![p1BrandName])
stock = DLookup("[StockOnHand]", "tblVaccine", "[VaccineID]= test"
computedStock = stock - 1
****computedStock is the now the updated stock hand. HOW DO I ASSIGN THIS TO THE SPECIFIC RECORD I WANT TO UPDATE?****
End Function
Again, thank you very much for your patience. Any help would be greatly appreciated. =)