If Statement not working

connerlowen

Registered User.
Local time
Yesterday, 23:56
Joined
May 18, 2015
Messages
204
HI,

I have a form with only one field visible on open. I have a combo box "PartOrAssembly" that I want to determine what fields will be made visible. My code in the Form_Current()

Private Sub Form_Current()
Me.NumberOfParts.Visible = False
Me.NumberOfPreciousMetals.Visible = False
Me.NumberOfBaseMetals.Visible = False
Me.MinimumBatch.Visible = False
Me.NumberOfAssemblies.Visible = False

Me.NumberOfParts.Enabled = True
Me.NumberOfPreciousMetals.Enabled = True
Me.NumberOfBaseMetals.Enabled = True
Me.MinimumBatch.Enabled = True
Me.NumberOfAssemblies.Enabled = True
End Sub

My code in the PartOrAssembly_AfterUpdate()

Private Sub PartOrAssembly_AfterUpdate()
' test the value entered by user in the category field and hide fields as required
If Me.NewRecord Then

If Me.PartOrAssembly = "Assembly" Then
Me.NumberOfAssemblies.Visible = True
Else
Me.NumberOfParts.Visible = True
Me.NumberOfPreciousMetals.Visible = True
Me.NumberOfBaseMetals.Visible = True
Me.MinimumBatch.Visible = True
End If
End If
End Sub

When the "PartOrAssembly" combo box is updated the code jumps to the Else condition regardless of the selection. The first part of the If condition is not running. What do I need to do to prevent this?

Thanks, Conner
 
Since it's a combo, make sure the bound colum isn't an ID field. You may need the ID there.
 
What do you mean? there is an ID field within the table. The table is AssyOrPartT with fields AssyOrPartID and Option. The lookup is for both, but only the Option field is shown. What do I need to change?
 
Try the ID instead of the text.
 

Users who are viewing this thread

Back
Top Bottom