Checkboxes acting strange (1 Viewer)

Yiannis_cy

Registered User.
Local time
Today, 12:11
Joined
Jul 29, 2010
Messages
16
Hi guys,

This is my first post!!!

Ok here's the story. i am creating a database for a local doctor which is somehow simple since he wants to enter only basic patient information. He wants to be able to click if someone for example had a heart attack which will present another question asking when did it happen but if he selects that the person didnt had a heart attack then he doesnt want the question to pop up. to do that i made the second question not visible and i set the mouse down (for radio buttons) and on click (for checkboxes) parameters to secondquestion.visible=true. In the same way i did the opposite for mouse up (for checkboxes) secondquestion.visible = false
in order to make it disappear if he accidentally selects yes and then he changes his mind. The problem in that when i uncheck the checkbox the second question does not become hidden, i have to doubleclick sometimes triple click....
any ideas?

thank you
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 12:11
Joined
Aug 30, 2003
Messages
36,124
Rather than the mouse events, I'd use the after update event of the checkbox. Use an If/Then/Else block to set the visibility appropriate to the checkbox value.
 

Yiannis_cy

Registered User.
Local time
Today, 12:11
Joined
Jul 29, 2010
Messages
16
can you please help me a little bit with the syntax?

should it be something like =if(checkbox1=true, Label1.visible=False)?


that cant be right :)
 

YNWA

Registered User.
Local time
Today, 20:11
Joined
Jun 2, 2009
Messages
905
I use this code.

The user checks a checkbox called fldSCR when they check this a text box appears called txtDateSCR for them to enter a date. If they uncheck the box then the text box disappears.

You could use this set up. Do you need to use a radio button?

IF you just had a set of questions (check boxes) then a field next to them for the dates then this code could be applied to each question.

Private Sub Form_Current()
If Me.fldSCR = -1 Then
Me.txtDateSCR.Visible = True
Else
Me.txtDateSCR.Visible = False
End If
End Sub


Private Sub fldSCR_AfterUpdate()
If Me.fldSCR = -1 Then
Me.txtDateSCR.Visible = True
Else
Me.txtDateSCR.Visible = False
Me.txtDateSCR.Value = Null
End If
End Sub
 

vbaInet

AWF VIP
Local time
Today, 20:11
Joined
Jan 22, 2010
Messages
26,374
Yianis cy:
Code:
Label1.visible=(Nz(checkbox1,0)=False)
YNWA: you could use just this too:
Code:
Me.txtDateSCR.Visible = Nz(Me.fldSCR, 0)

For the Null part you still need an IF block:
Code:
If Not Nz(Me.fldSCR,0) = -1 Then
    Me.txtDateSCR.Value = Null
End If
 

Users who are viewing this thread

Top Bottom