Help with "Visible" Code

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form that has a drop down box Part_Type and there are 2 selections
inside: Raw Material and Purchased Component - for this field I have the
following code:

Private Sub Part_Type_AfterUpdate()

If [Part_Type] = "Purchased Component" Then
[UOM] = "ea" & [Part_Weight].Visible = False
ElseIf [Part_Type] = "Raw Material" Then
[UOM] = "lb." & [Part_Usage].Visible = False
End If

End Sub

FYI, Part Weight & Part Usage are Number fields.

I want it to do 2 things, first change UOM to "ea" or "lb" which works ok by
itself but then I want the field "Part Usage" or "Part Weight" to not be
visible depending on the Part_Type.

Do I have the code wrong??

Thanks!!!!
 
Use 2 separate lines:
[UOM] = "ea"
[Part_Weight].Visible = False

The ampersand (&) is for string concatentation. As written, you are not
setting the visible property of the field, just evaluating it's current
setting. VB will set [UOM] to either "eaTrue" or "eaFalse", depending on
whether '[Part_Weight].Visible = False' is T or F.

(BTW, once you have this working, do you have provisions for turning
[Part_Weight] and [Part_Usage] visible again, when appropriate, somewhere
else in your code?)

HTH,
 
Awesome, that worked.
Thanks!!

George Nicholson said:
Use 2 separate lines:
[UOM] = "ea"
[Part_Weight].Visible = False

The ampersand (&) is for string concatentation. As written, you are not
setting the visible property of the field, just evaluating it's current
setting. VB will set [UOM] to either "eaTrue" or "eaFalse", depending on
whether '[Part_Weight].Visible = False' is T or F.

(BTW, once you have this working, do you have provisions for turning
[Part_Weight] and [Part_Usage] visible again, when appropriate, somewhere
else in your code?)

HTH,
--
George Nicholson

Remove 'Junk' from return address.


SMac said:
I have a form that has a drop down box Part_Type and there are 2 selections
inside: Raw Material and Purchased Component - for this field I have the
following code:

Private Sub Part_Type_AfterUpdate()

If [Part_Type] = "Purchased Component" Then
[UOM] = "ea" & [Part_Weight].Visible = False
ElseIf [Part_Type] = "Raw Material" Then
[UOM] = "lb." & [Part_Usage].Visible = False
End If

End Sub

FYI, Part Weight & Part Usage are Number fields.

I want it to do 2 things, first change UOM to "ea" or "lb" which works ok
by
itself but then I want the field "Part Usage" or "Part Weight" to not be
visible depending on the Part_Type.

Do I have the code wrong??

Thanks!!!!
 
Back
Top