Hide check box if text box is blank

W

WembleyBear

Hi

I've had a look through some other similar discussions here but haven't been
able to work out what I need to do here. I have a check box on my form called
ActComplete and beside it a text box that is called ActDesc.

The text box refers to a column in another table using
=[Incident_Type].Column(3) which is filled in depending on the choice from a
drop-down box called Incident_Type. However, sometimes (and correctly) the
Column(3) contains no information and so my text box shows as blank on the
form - which is fine, but in this situation, I would like the check box to be
hidden - how can I do this? (in easy steps, please!)

Thanks for your advice

Martyn

Access 2000, Windows 2003 server over Citrix PS4
 
R

Ron2006

Here are some thoughts, but the real answer depends on the
relationship of the forms which is not clear from your description.

1) one possibility is in the afterupdate of the combo box put
if isnull(me.Incident_Type.column(3) then
me.chkboxname.visible = false
else
me.chkboxname.visible = true
endif

Basically it comes down to some event has to be triggered that then
makes the test either to the combobox column 3 value or the txtbox
value for null and set the chkbox visibility appropriately. That can
be onopen or onload or oncurrent of the form if the items are on
different forms (maybe) or just the afterupdate of the combo if the
chkbox field is addressable at that time.

We need more information to give a more specific answer.

Ron
 
W

WembleyBear

Hi Ron

Thanks for your thoughts - I tried the code in the After Update event of the
combo box but it did not work. Sorry if I did not make myself clear. I'll try
again:

I have only one form, based on one table called Incidents. On the form is a
combo box field from this table called Incident_Type, which looks up it's
values from the first column in another table - Incident_Policy. A user must
select a value from this list on the form.

In the Incident_Policy table the 4th column contains details of a policy or
procedure number that must be read and agreed to.

Back to the main Incidents form; this then contains a text box called
ActDesc, which is not connected to any table as I did not want to store this
value. Instead, I used

=[Incident_Type].Column(3)

to display the policy details only on the form. Beside this is a check box
called ActComplete which IS a field in the Incidents main table. This was
intended as a visual check only to confirm that the user has seen the details
of the relevant policy number, but some incidents do not have an associated
policy at all, hence no text in column 4 of those rows of the Incident_Policy
table, and I do not want the check box to show on the form in that instance.


Hope this makes more sense

Martyn
 
R

Ron2006

Ok, we will both try again.

1) is it Datasheet, Continuous or Single Form?

2) Is the presense of the value in the txtbox appear as you intend or
want it to?

Ron
 
W

WembleyBear

Hi

1) Single form.

2) Yes, when there is text in that column it shows in the text box as per
the item selected from the combo box list. When theres nothing there, nothing
shows - perfect.


I have question though, does the presence of =[Incident_Type] etc in the
text box on the form prevent the IsNull from seeing that box as null?


Martyn
 
R

Ron2006

My gut feel is no.

Have you tried pointing the condition test to the combox.column(3)
instead of the txt box? That would eliminate any possible confusion.

Also in this case the condition code needs to be in both the onCurrent
and the afterupdate.
Afterupdate resets it for when new info is selected in the
combo
and
OnCurrent sets it for existing records, for which you are NOT
change the value.

Ron
 
W

WembleyBear

We're getting there - it half works now. I have the following code in the
OnCurrent and AfterUpdate events of the form:

If IsNull(Me.[Incident_Type].Column(3)) Then
Me.ActCompleteVisible = False
Else
Me.ActComplete.Visible = True
End If

Now, when I go to enter a new record, the check box is not visible at first
(which is fine as no option has yet been selected from the combo). But when I
select an option with a policy, the text box displays the policy info, but
the check box does not display at all.
 
R

Ron2006

Because it is in the afterupdate it will not display until you get off
of the field.

If you have limit to list set to Yes then you could do it also in the
after change event. This causes it to be done "more frequently" but
not too much depending on how many keystroks it takes to get to the
value you will accept. since each keystroke is a change in the value.

Try to have an intermediate field to tab to after the combo so you can
check the afterupdate

Ron
 
W

WembleyBear

Well, I have the code as before in the AfterUpdate & OnCurrent events of the
form and the OnChange event of the Incident_Type combo. It works, but if you
go back and re-select from the list to an incident without a policy detail,
the wording in the text box goes, but the check box remains. This is a
problem as the user might accidentally select the wrong incident type and
have to go back and reselect, but the check box remains whatever. How could I
get around this - it's so nearly exactly what I wanted?
 
A

Allen Browne

If the check box is for display purposes only, you could replace it with a
text box that uses a Winddings character to simulate a text box.

You can then use Conditional Formatting (instead of writing code) to hide
the contents of the text box (e.g. white on white.)

This article explains how:
Format check boxes in reports
at:
http://allenbrowne.com/ser-52.html
(I realise you're doing this in a form.)
 
R

Ron2006

I just test the suggested logic, and it worked as expected. The only
difference is that I was testing for a specific value as opposed to
NULL.

I would suggest that you might change the test around and/or verify
something.
1) instead of testing for null, change the test to say
len(me.combobox.column(3)) = 0
this can work equally for really null values and some 0 length
items.

2) verify that you have both sides of the if statement present. if
then else endif
both sides need to be actively working on the visible aspect of
the check box.

Ron
 
W

WembleyBear

Ron

Thanks for your continued input - I will try these out and see if one of
them does the trick.

Martyn
 
W

WembleyBear

Ron

I've just tried this and it works perfectly & as I want it to. Many thanks
for all your help.


Martyn
 

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