disable field until several other fields filled

G

Guest

I'm trying to disable access to a particular field until data is entered into
3 others first. I have been unable to adapt the solution to a similar
problem (where only one field requires entry to enable several others) posted
by Nikos Yannacopoulos:
---
Assuming the combo name is cboUser and the other four controls are named
ctrl1 through ctrl4 (and you change the control names to the actual ones),
use the combo's Before Update event to run the following code:

Dim cboStatus As Boolean
cboStatus = IsNull(Me.cboUser)
Me.ctrl1.Enabled = Not cboStatus
Me.ctrl2.Enabled = Not cboStatus
Me.ctrl3.Enabled = Not cboStatus
Me.ctrl4.Enabled = Not cboStatus

The Enabled property of the four controls should be set to No in the form
design, so they are not enabled when the form opens. Alternatively, you
could run the exact same code in the form's On Open event
 
J

Jamie Richards

Hi,

There must be a thousand ways to do this, many of them far more complex than
what I am about to propose. However this is simple and may help you.

Private Sub Field1_Enter()
With Me
If (IsNull(.Field2) Or IsNull(.Field3) Or IsNull(.Field4)) Then
MsgBox "Please fill out fields 2 and 3 and 4 before entering
data in field 1."
.Field2.SetFocus 'send the focus somwhere else to get it off the
control you are protecting
End If
End With
End Sub

Where:
* Field1 is the field you want to protect form data entry until
condition the others have data
* Fields 2 and 3 are the ones you want filled out first

Hope this helps

Jamie
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top