Subform runtime error

  • Thread starter Thread starter Morgan Gartland via AccessMonster.com
  • Start date Start date
M

Morgan Gartland via AccessMonster.com

I have a form that shows suppliers and a subform that shows the products
they supply. Some companies supply products in Bin sizes and other
companies supply products in lot sizes.

When a companies details are up on screen the following code shows me only
lot size or bin size dependant on which fields have been filled in on the
sub form.

Private Sub Form_Current()
If Me![Product_Subform]![BinSize] <> vbNullString Then
Me![Product_Subform]![BinSize].Visible = True
Me![Product_Subform]![BinSizelbl].Visible = True
Me![Product_Subform]![LotSize].Visible = False
Me![Product_Subform]![LotSizelbl].Visible = False
Else
Me![Product_Subform]![LotSize].Visible = True
Me![Product_Subform]![LotSizelbl].Visible = True
Me![Product_Subform]![BinSize].Visible = False
Me![Product_Subform]![BinSizelbl].Visible = False
End If
End Sub
--
i have previously had the first line as
If Me![Product_Subform]![BinSize] > 0 Then
--
My problem is when there is a company with no products at all i get the
"Run-Time Error '2427': the expression you have entered has no value". I
understand why i am getting this message but i cannot seem to be able to
rectify it. If anyone could help me out it would stop my head from exploding

Cheers
Morgan
 
Some error handling would do the job.
Some aircode:


Private Sub Form_Current()
On Error Goto ProcedureError
If Me![Product_Subform]![BinSize] <> vbNullString Then
Me![Product_Subform]![BinSize].Visible = True
Me![Product_Subform]![BinSizelbl].Visible = True
Me![Product_Subform]![LotSize].Visible = False
Me![Product_Subform]![LotSizelbl].Visible = False
Else
Me![Product_Subform]![LotSize].Visible = True
Me![Product_Subform]![LotSizelbl].Visible = True
Me![Product_Subform]![BinSize].Visible = False
Me![Product_Subform]![BinSizelbl].Visible = False
End If
ProcedureExit:
Exit Sub
ProcedureError:
If Err.Number <> 2427 Then
Msgbox "Error: " & Err.Number & vbNewLine & "Description: " &
Err.Description
End If
Resume ProcedureExit
End Sub


Regards,
Andreas
 
Back
Top