Remove a entry field if condition is null on form

M

Matt

hello,
I have two tables one where information is entered from a form and the other
table is just a list of only 12 records that remain constants they are (Name,
ID, & Baseline), but only 7 of the 12 records need baselines.

In the form the user enters the name from a dropdown box and then they enter
a percent into one field and a number into another. Is there a way depending
on the name you choose from the dropdown list to remove one of the fields
that you don't need to enter any info into.
So, for example if the baseline field in the table of constants is
null/empty, then remove that field from the form. I want to do this to
minimize user confusion, because they dont need to enter anything into the
number field if the baseline is null.
Can this be done?
 
W

Wayne-I-M

Private Sub SomeCombo_AfterUpdate()
If IsNull([SomeCombo].Column(#)) Then
Me.SomeTextBox.Visible = False
Else
Me.SomeTextBox.Visible = True
End If
End Sub
 
K

Klatuu

Yes. You can use the After Update event of the combo box to check to see if
there is a value in the column of the combo box that might be Null. That
field from the small table has to be included in the combo's row source, of
course. Note that column numbers in a combo start with 0, so if your row
source is like:
SELECT ID, Name, BaseLine FROM SmallTablle;

And the BaseLine field is the column you want to test, you would use
Column(2).

So as an example, let's say you want to hide a control named txtPct if the
column is NUll, it would be:

Me.txtPct.Visible = Not IsNull(Me.MyCombo.Column(2))

That will make the control visible if it is not Null and hidden if it is.

But, you still have to take care of other existing records. To do that, you
would use the Form Current event to set the control to Visible or not
depending on the value in the control itself.

Me.txtPct.Visible = Not IsNull(Me.txtPct)
 
R

Ryan

Use the after update event of the combo box to change the disable the fields.
It would look something like this.

If Me!YourComboBoxName = "OneOfTheNamesThatDoesntNeedaBaseline" Then
Me!Baseline.Enabled = False
End If

You can use Case if there are multiple selections. It would look like this
Select Case NameOfYourComboBox
Case "OneOfTheNamesThatDoesntNeedaBaseline"
Me!Baseline.Enabled = False
Case "AnotherOneOfTheNamesThatDoesntNeedaBaseline"
Me!Baseline.Enabled = False
End Select

Hope this helps
 
M

Matt

Where do i enter that expression?

Klatuu said:
Yes. You can use the After Update event of the combo box to check to see if
there is a value in the column of the combo box that might be Null. That
field from the small table has to be included in the combo's row source, of
course. Note that column numbers in a combo start with 0, so if your row
source is like:
SELECT ID, Name, BaseLine FROM SmallTablle;

And the BaseLine field is the column you want to test, you would use
Column(2).

So as an example, let's say you want to hide a control named txtPct if the
column is NUll, it would be:

Me.txtPct.Visible = Not IsNull(Me.MyCombo.Column(2))

That will make the control visible if it is not Null and hidden if it is.

But, you still have to take care of other existing records. To do that, you
would use the Form Current event to set the control to Visible or not
depending on the value in the control itself.

Me.txtPct.Visible = Not IsNull(Me.txtPct)
 
M

Matt

Ok, the way you described seems to be working better then the other ways, it
is removing the text box that I wanted but it is removing it no matter what I
select from the list of names(or what i am calling functions).

Wayne-I-M said:
Private Sub SomeCombo_AfterUpdate()
If IsNull([SomeCombo].Column(#)) Then
Me.SomeTextBox.Visible = False
Else
Me.SomeTextBox.Visible = True
End If
End Sub



--
Wayne
Manchester, England.



Matt said:
hello,
I have two tables one where information is entered from a form and the other
table is just a list of only 12 records that remain constants they are (Name,
ID, & Baseline), but only 7 of the 12 records need baselines.

In the form the user enters the name from a dropdown box and then they enter
a percent into one field and a number into another. Is there a way depending
on the name you choose from the dropdown list to remove one of the fields
that you don't need to enter any info into.
So, for example if the baseline field in the table of constants is
null/empty, then remove that field from the form. I want to do this to
minimize user confusion, because they dont need to enter anything into the
number field if the baseline is null.
Can this be done?
 
M

Matt

This is what I have:

Private Sub Function_AfterUpdate()
If IsNull([Function].Column(2)) Then
Me.ResponseTime.Visible = False
Else
Me.ResponseTime.Visible = True
End If
End Sub

Wayne-I-M said:
Private Sub SomeCombo_AfterUpdate()
If IsNull([SomeCombo].Column(#)) Then
Me.SomeTextBox.Visible = False
Else
Me.SomeTextBox.Visible = True
End If
End Sub



--
Wayne
Manchester, England.



Matt said:
hello,
I have two tables one where information is entered from a form and the other
table is just a list of only 12 records that remain constants they are (Name,
ID, & Baseline), but only 7 of the 12 records need baselines.

In the form the user enters the name from a dropdown box and then they enter
a percent into one field and a number into another. Is there a way depending
on the name you choose from the dropdown list to remove one of the fields
that you don't need to enter any info into.
So, for example if the baseline field in the table of constants is
null/empty, then remove that field from the form. I want to do this to
minimize user confusion, because they dont need to enter anything into the
number field if the baseline is null.
Can this be done?
 
R

Ryan

Private Sub Function_AfterUpdate()
Select Case Function
Case "One of the values in your combo you dont want to see the response time
on"
Me!ResponseTime.Visible = False
Case "Add a case for each value in your combo you dont want to see response
times for"
Me!Responsetime.Visible = False
End Select
End Sub


Matt said:
This is what I have:

Private Sub Function_AfterUpdate()
If IsNull([Function].Column(2)) Then
Me.ResponseTime.Visible = False
Else
Me.ResponseTime.Visible = True
End If
End Sub

Wayne-I-M said:
Private Sub SomeCombo_AfterUpdate()
If IsNull([SomeCombo].Column(#)) Then
Me.SomeTextBox.Visible = False
Else
Me.SomeTextBox.Visible = True
End If
End Sub



--
Wayne
Manchester, England.



Matt said:
hello,
I have two tables one where information is entered from a form and the other
table is just a list of only 12 records that remain constants they are (Name,
ID, & Baseline), but only 7 of the 12 records need baselines.

In the form the user enters the name from a dropdown box and then they enter
a percent into one field and a number into another. Is there a way depending
on the name you choose from the dropdown list to remove one of the fields
that you don't need to enter any info into.
So, for example if the baseline field in the table of constants is
null/empty, then remove that field from the form. I want to do this to
minimize user confusion, because they dont need to enter anything into the
number field if the baseline is null.
Can this be done?
 

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