Locking a field/button until another has been completed

fireman_gcfd

Registered User.
Local time
Today, 13:43
Joined
Aug 14, 2007
Messages
25
Hello All,

I have been surfing the forums and have found many ideas/paths to follow for what I am looking to do. I am just hoping for some clarity and hopefully simplicity.

I am trying to lock down (for lack of a better term) a field "Incident", which is populated by a button that adds to the last number generated on previous records. I would like this button disabled until the field "Platoon Chief" has been filled out.

What would be the easiest solution for this? I am having too many blank records from people mistakenly clicking the Incident button then closing out the form.

See attached.

Thank You,
Jaz
 

Attachments

OK, so I successfully disabled the button with the suggested code but I am having a little trouble with getting it enabled even with populating the other field. Here is what I have in the Form_Current:

Private Sub Form_Current()
If Me.PlatoonChief = Null Then
Me.IncidentBtn.Enabled = True
Else
Me.IncidentBtn.Enabled = False
End If
End Sub

Can you tell me where I went wrong?

Thanks again
 
Nothing is "=" to Null. Try

If Len(Me.PlatoonChief & vbNullString) = 0 Then

which tests for both Null and ZLS. To just test for Null:

If IsNull(Me.PlatoonChief) Then

Isn't your logic reversed?
 
My logic reversed?? Could be...I may be looking at this from the wrong angle. Where do you see it reversed?
 
Your logic is "if the field is null, enable the button, otherwise disable it". I thought you wanted it the other way around.
 
You are absolutely correct!!! Thank you. I used the "If IsNull" and rearranged my True and False and it works great.

I appreciate the help.
 
No problemo, glad we got it working.
 
This worked great for me too. I used it against a Command Button... The only thing I can't figure out, is how to get the button to "re-enable" once the fields are filled in. Any advise would be much appreciated....


Private Sub Form_Current()

If IsNull(Me.LName) & Len(Me.FName) & Len(Me.Rank) & Len(Me.Unit) & Len(Me.Shift) & Len(Me.Reason) Then
Submit.Enabled = False
Else
Submit.Enabled = True
End If
End Sub
 
Nothing is "=" to Null. Try

If Len(Me.PlatoonChief & vbNullString) = 0 Then

which tests for both Null and ZLS. To just test for Null:

If IsNull(Me.PlatoonChief) Then

Isn't your logic reversed?


This worked great for me too. I used it against a Command Button... The only thing I can't figure out, is how to get the button to "re-enable" once the fields are filled in. Any advise would be much appreciated....


Private Sub Form_Current()

If IsNull(Me.LName) & Len(Me.FName) & Len(Me.Rank) & Len(Me.Unit) & Len(Me.Shift) & Len(Me.Reason) Then
Submit.Enabled = False
Else
Submit.Enabled = True
End If
End Sub
 
Did you see the link in post 2? Also, I'd use OR between the tests.
 
I did and I tried that. Nothing the command button stays disabled after you enter the required information. I am at a loss...
 
You have no logical test for all the subsequent Len statements.

Code:
If IsNull(Me.LName) OR Len(Me.FName & vbNullString)=0  OR Len(Me.Rank & vbNullString)=0  OR Len(Me.Unit & vbNullString)=0 OR Len(Me.Shift & vbNullString)=0  OR Len(Me.Reason  & vbNullString)=0  Then

And you should be using Me.Submit.Enabled = True

...edit
AND you are using this on form_current - which won't fire after one or more field is updated, only if you move from record to record.

You would need to check after each fields after update event.
 
Still no change....

Trying to make it that once a user enters all the info in the red fields (Capture.jpg) the "Submit" button is then Enabled.
 

Attachments

  • Capture.JPG
    Capture.JPG
    39.1 KB · Views: 113
Last edited:
Private Sub Form_Current()
If IsNull(Me.LName) = 0 Or Len(Me.FName & vbNullString) = 0 Or Len(Me.Rank & vbNullString) = 0 Or Len(Me.Unit & vbNullString) = 0 Or Len(Me.Shift & vbNullString) = 0 Or Len(Me.Reason & vbNullString) = 0 Then
Me.Submit.Enabled = False
Else
Me.Submit.Enabled = True
End If
End Sub

Private Sub LName_AfterUpdate()
If IsTrue Then
Me.Submit.Enabled = True
Else
Me.Submit.Enabled = False
End If
End Sub

Private Sub FName_AfterUpdate()
If IsTrue Then
Me.Submit.Enabled = True
Else
Me.Submit.Enabled = False
End If
End Sub

Private Sub Rank_AfterUpdate()
If IsTrue Then
Me.Submit.Enabled = True
Else
Me.Submit.Enabled = False
End If
End Sub

Private Sub Reason_AfterUpdate()
If IsTrue Then
Me.Submit.Enabled = True
Else
Me.Submit.Enabled = False
End If
End Sub

Private Sub Shift_AfterUpdate()
If IsTrue Then
Me.Submit.Enabled = True
Else
Me.Submit.Enabled = False
End If
End Sub

Private Sub Unit_AfterUpdate()
If IsTrue Then
Me.Submit.Enabled = True
Else
Me.Submit.Enabled = False
End If
End Sub
 
Last edited:
What is IsTrue? If a function, what the code?
 

Users who are viewing this thread

Back
Top Bottom