J
Jamie Dickerson
I have a form (Production Reports) where work performed by plant personnel is
recorded. I have a a field on the form (standard) where the quota must be
entered manually. I would like to have this field auto populate based on the
item# and machine ID. I have set up a table (Standards) with the following
fields:
Machine ID (number)
Item# (Text)
Standard (number)
I have placed the following code in the AfterUpdate Event of the machine
type combo box:
Dim myStandard As Long
If IsNull(Machine) Then
MsgBox "Please choose a machine."
Cancel = True
Exit Sub
End If
myStandard = Nz(DLookup("Standard", "tblStandards", "MachineID = " &
MachineID & -" AND Item = " & Item), -1)
If myStandard = -1 Then
MsgBox "Could not find standard value for this combination of Machine & Item
#."
Else
Standard = myStandard
End If
I am recieving runtime errors (type mismatch). The debugger highlights the
line containg the DLookUp function. Can someone please tell me what I am
missing, or what I have done wrong?
Thanks in advance.
recorded. I have a a field on the form (standard) where the quota must be
entered manually. I would like to have this field auto populate based on the
item# and machine ID. I have set up a table (Standards) with the following
fields:
Machine ID (number)
Item# (Text)
Standard (number)
I have placed the following code in the AfterUpdate Event of the machine
type combo box:
Dim myStandard As Long
If IsNull(Machine) Then
MsgBox "Please choose a machine."
Cancel = True
Exit Sub
End If
myStandard = Nz(DLookup("Standard", "tblStandards", "MachineID = " &
MachineID & -" AND Item = " & Item), -1)
If myStandard = -1 Then
MsgBox "Could not find standard value for this combination of Machine & Item
#."
Else
Standard = myStandard
End If
I am recieving runtime errors (type mismatch). The debugger highlights the
line containg the DLookUp function. Can someone please tell me what I am
missing, or what I have done wrong?
Thanks in advance.