PstWood
asked on
Run-time error '3162'
I have an after-update event procedure for a combo box that populates a second combo box with the following:
Private Sub CategoryID_AfterUpdate()
Me!ProductID.Requery
ProcuctID = PruductID.ItemData(0)
End Sub
The problem is that if a category is selected in which there are no products, I get a Run-time error '3162' saying that I tried to assign a null valuable to a variable that isn't a variant data type.
How can I get around this?
Thanks.
RWW
Private Sub CategoryID_AfterUpdate()
Me!ProductID.Requery
ProcuctID = PruductID.ItemData(0)
End Sub
The problem is that if a category is selected in which there are no products, I get a Run-time error '3162' saying that I tried to assign a null valuable to a variable that isn't a variant data type.
How can I get around this?
Thanks.
RWW
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
btw this assumes that ProcuctID IS a variable ...(since access is assuming it is)
if you are trying to assign a value to a control (textbox) do this
me!ProcuctID = iif(isnull(PruductID.ItemD ata(0)), "", PruductID.ItemData(0))
if you are trying to assign a value to a control (textbox) do this
me!ProcuctID = iif(isnull(PruductID.ItemD
ASKER
Thanks.
RWW
RWW
ASKER
I did have to put a second Me!ProductID.Requery after the End If in order to clear the box if the user chooses a category, then changes his mind and chooses another.
What about this
Private Sub CategoryID_AfterUpdate()
Me!ProductID.Requery
If Me.ProductID.Listcount<>0 Then
ProcuctID = PruductID.ItemData(0)
Else
ProductID = ""
End If
End Sub
Mike
Private Sub CategoryID_AfterUpdate()
Me!ProductID.Requery
If Me.ProductID.Listcount<>0 Then
ProcuctID = PruductID.ItemData(0)
Else
ProductID = ""
End If
End Sub
Mike
Dim ProductID as Variant
otherwise you'll have to trap for null
ProcuctID = iif(isnull(PruductID.ItemD