Show and hide field with textbox

mickelingon

Registered User.
Local time
Today, 18:04
Joined
Feb 3, 2006
Messages
72
Hi

How do I easy create a checkbox that displayes a field when I check it.
For example, if I check a box named I agree, it shows a field with a phonenumber to call

Mike
 
The On-Click event of the checkbox, sets or resets the .visible property of the text box you want to hide or display.
Me.MyTextBox.Visible = true ' to display false to hide
 
I'm quit new to this and is not shure how to do it step by step.
I have a table with the fields "own initiativ, referral and diagnosis"
I have a form with checkboxes "own initiativ" and "referral"
When I check the "referral" checkbox I want to display the field "diagnosis" or the text in it (if any).
How do I do

Thanks for all help

Mikael
 
Under events for referral checkbox, create a procedure on the CLICK event
Put the following in this event.
' if the checkbox is checked, show the diagnosis field
If Me.referral = true then Me.diagnosis.visable = true
' if the checkbox is not checked, hide the diagnosis field
If Me.referral = false then Me.diagnosis.visable = false

Same for the other checkbox but change the names of the controls.
 
Hi

I must be stupid, but probably I'm doing it completly wrong.
I attached the .db and it's the "väg in" form on the that I can't get to work.
Feel free too make changes. (it's made in access 2002)
Sorry about it beeing in swedish.

What I want is a function that you only can choose one of the checkboxes at a time.
And if you check the checkbox "remiss" it should display text in the text boxes remittent and diagnos.

Thanks for all help
 

Attachments

OK but the text boxes are/should be picking up the data from the bound fields the form is based on. So how does the checkbox com into play then? I mean if there is data in the table behind those fields, is it suppose to be hiden until the check box is checked, or does the checking of the box suppose to put soemthing in the text boxes?
And when you say only reference one at a time, does that mean if one is checked, it would UNCHECK the other?
 
I think I got it.

On load of the form:
Private Sub Form_Open(Cancel As Integer)
If Egetinitiativ = False Then
Me!Diagnos.Visible = False
End If
If Remis = False Then
Me!Remittent.Visible = False
End If
End Sub

For the 1st check box:
Private Sub Egetinitiativ_Click()
If Egetinitiativ = True Then
Me!Diagnos.Visible = True
End If
If Egetinitiativ = False Then
Me!Diagnos.Visible = False
End If
End Sub

2nd check:
Private Sub Remiss_Click()
If Remiss = True Then
Me!Remittent.Visible = True
End If
If Remiss = False Then
Me!Remittent.Visible = False
End If
End Sub

Not sure if I have the check boxes corresponding to the correct text box, but you can change that.

I've attached it.
 

Attachments

Hi,
Now we are almost there.
The problem now is that this is a subform in a search form and it's bound to ID.
And when I search and display a new person and the person before had the checkbox for "eget initiativ" checked.
The new found person also gets the same checkbox checked.

So i guess what I want is when the searchform updates the subform will update to. Or am I thinking the wrong way?

Mikael
 
mickelingon said:
Hi,
Now we are almost there.
The problem now is that this is a subform in a search form and it's bound to ID.
And when I search and display a new person and the person before had the checkbox for "eget initiativ" checked.
The new found person also gets the same checkbox checked.

So i guess what I want is when the searchform updates the subform will update to. Or am I thinking the wrong way?

Mikael

Do you have a button or something that the user clicks to search for the next record?

Do you have a button for the user to check next record, you could change the focus back to the main form onClick and also set the check box properties back to false....I think.
 
Hi

No, I just hit enter to do the search.
I can create a button if that will help

Please advice

Mikael
 
Hi

I have to rethink and change the way of display in my form.

I have a form bound to ID.
I want to show 2 fields if they contain data, otherwise hide them
How do you do that?

Micke
 

Users who are viewing this thread

Back
Top Bottom