Showing hidden fields when box is ticked

Bloodrayne

Newbie-rrific!
Local time
Today, 23:23
Joined
Oct 6, 2004
Messages
58
Hello,

I've been busily working on an Access database for the past few days, and would like to see if it was possible to make a (purely cosmetic) change - basically, there's a set of fields - Flight Requested, Flight Booked, Flight Booked with - Flight Requested and Booked are both tick boxes, I would like to make it so that if Flight Requested is not ticked - the other fields are not shown...

So, I have to make those fields invisible - and then perform an action when Flight Booked is clicked... here's where I need the help - what kind of action would I need to do?

Thanks!
 
try using something similar to the following:

If Me.FlightRequested = False Then
Me.FlightBooked.Visible = False
Else
Me.FlightBooked.Visible = True
End If
 
That, my newly found hero, is fabulous!

Ta Muchly
 
Ahhh...

Except - if I'm applying this to a currently existing database, is there anyway I can have the code check for a tick in the box first? So a tick always means that the fields are visible?
 
If you mean have the form check a tickbox value -- and then react one way or another -- as you move to a different record, you can put code like the following in the form's On Current event.

Code:
If me.checkboxName = 1 then
   'it's selected
   'hide or not hide controls and labels here
End if

Regards,
Tim
 
Hi,

Simply copy the above code to the Form's Open or Load events. (Better programming practice would be to create a sub and call it from both places).

Keith.
 
How do I get to the forms Open/Load events?

Cheers for all the help - tis a great forum
 
in your form design, goto View -> Properties -> Event
 
Ah - I'd left something selected, that's why I couldn't find it!

Thanks a lot!
 
Still no joy, here's my code:

Code:
Private Sub Form_Open(Cancel As Integer)
If Me.Flight_requested = 1 Then

Me.Flight_Booked.Visible = True
Me.Flight_Booked_Label.Visible = True
Me.Flight_Booked_with.Visible = True
Me.Flight_Booked_with_Label.Visible = True


Else

If Me.Flight_requested = False Then
Me.Flight_Booked.Visible = False
Me.Flight_Booked_Label.Visible = False
Me.Flight_Booked_with.Visible = False
Me.Flight_Booked_with_Label.Visible = False


End If
End Sub

Which is a combination of the previous two submissions (thanks for those), and this still doesn't work...

Would appreciate some more guidance
 

Users who are viewing this thread

Back
Top Bottom