Should be Easy

Status
Not open for further replies.

SteelersFan

Registered User.
Local time
Today, 14:21
Joined
Feb 9, 2005
Messages
38
I want to have code that disables fields based on the value of the contents of one of the fields. I wrote this code which goes on and on but it doesn't work. Can someone help?

Private Sub Form_Open(Cancel As Integer)

Dim Item_Number As String

If Me.Item_Number = "300123C" Then
Me.Batch_Lot_Number.Enabled = False
Me.Issue_Date.Enabled = False
Me.Production_to_BPT.Enabled = True

Elseif blah blah blah

else blah


Endif

End sub
 
If you slip a message box in your code, you will see the value you are trying to compare to.

Code:
If Me.Item_Number = "300123C" Then
MsgBox " ItemNo Value " & Item_Number
Me.Batch_Lot_Number.Enabled = False

My guess is that the "Form Open" event is too early in the scheme of things to be able to extract the data from Item_Number, if that is the case your message box will not return a value, And you should try the code in the form load event.

There are other events which happen when the form opens, I'm not sure which one would be best, there is a list of the Invents order somewhere but I can't remember where it is!
 
Use the Form_Current event and what are all the elseif statements for?
 
Status
Not open for further replies.

Users who are viewing this thread

Back
Top Bottom