I built a form (Access97) with date fields and part number fields. When a part has been replaced in the equipment, I need to track the expense. To simplify data entry I used Dlookup (After Update) to lookup a price from a parts price table. This works great, but my problem is if someone enters a date by mistake and then deletes the date, the price is still in the table.
Sample of code:
txboxDate Field-After Update
If (Me!TypeOfPart = A) Then
txboxPrice = DLookup("[fldPartPrice]", "tblPartA", "[fldPrtNo] = '" & Me!PartNo & "'")
Else
If (Me! TypeOfPart = B) Then
txboxPrice = DLookup("[fldPartPrice]", "tblPartB", "[fldPrtNo] = '" & Me! PartNo & "'")
Else
If (Me! TypeOfPart = C) Then
txboxPrice = DLookup("[fldPartPrice]", "tblPartC", "[fldPrtNo] = '" & Me! PartNo & "'")
(This is the part I’m having trouble with, what is the best method of returning the value to zero if the date is deleted.)
Else
If IsNull(Me!txboxDate) Or Me!txboxDate = "" Then
?????
End If
End If
End If
End if
I’ve just started learning VBA so baby steps please.
Thanks
Gary
[This message has been edited by gMAC (edited 02-02-2002).]
Sample of code:
txboxDate Field-After Update
If (Me!TypeOfPart = A) Then
txboxPrice = DLookup("[fldPartPrice]", "tblPartA", "[fldPrtNo] = '" & Me!PartNo & "'")
Else
If (Me! TypeOfPart = B) Then
txboxPrice = DLookup("[fldPartPrice]", "tblPartB", "[fldPrtNo] = '" & Me! PartNo & "'")
Else
If (Me! TypeOfPart = C) Then
txboxPrice = DLookup("[fldPartPrice]", "tblPartC", "[fldPrtNo] = '" & Me! PartNo & "'")
(This is the part I’m having trouble with, what is the best method of returning the value to zero if the date is deleted.)
Else
If IsNull(Me!txboxDate) Or Me!txboxDate = "" Then
?????
End If
End If
End If
End if
I’ve just started learning VBA so baby steps please.
Thanks
Gary
[This message has been edited by gMAC (edited 02-02-2002).]