Checkbox On Change or is it something else?

fat controller

Slightly round the bend..
Local time
Today, 17:52
Joined
Apr 14, 2011
Messages
758
I have a form which has 5 checkboxes, and I am trying to get a textbox (txtnotes) to become visible if any/either/all of those text boxes is ticked.

Is my thinking correct that I will have to put an on change or on update event in for each text box, along the lines of

Code:
If me.checkbox1.value = -1 Then
me.txtnotes.visible = true
Else

me.checkbox1.setfocus
End If
End Sub
 
Thanks :)

I am using the visible command as a sort of 'gate' to stop people missing out certain parts of a form; in short, they enter an employee ID into an unbound textbox - that is then used as the value to see if a matching record already exists; if it doesn't then the value in that unbound textbox becomes the value in a bound text box kicking the new record off, and at that point the five checkboxes appear. Only when at least one of the five is checked will it open the notes field.

I have put the following code in as an On Change event, which seems to be working just fine :)

Code:
If me.checkbox1.value = True Then
me.txtnotes.visible=true

Else
me.checkbox2.setfocus

End If
End Sub
 
Per pbaldy's post in #2, a small function can be built and inserted in each of the checkbox's on change event.

Code:
Private Function CheckForNotesCheckboxes() as Boolean
 
   CheckForNotesCheckBoxes = Me.checkbox1 Or Me.CheckBox2 or Me.CheckBox3 or Me.CheckBox4 or Me.CheckBox5
 
End Function

Then in each checkbox On Change Event, it would be called:
Code:
me.txtNotes.Visible = CheckForNotesCheckboxes

Kind of rigid and doesn't allow for much flexibility, but it should work.
 
Would the first piece of code go in the General Declarations, or does it too go in the OnChange Event for each check box?
 
I would put the function CheckForNotesCheckboxes as a function in the General Declarations for the form in question.
 
Change, After Update, Click... any would do. It's a check box so all react a similar way but my preference would be After Update to keep the logic consistent.
 

Users who are viewing this thread

Back
Top Bottom