Making a Sub-Form visible using Check Box (Access 2000)

BlueChicken

Usually Confused
Local time
Today, 14:44
Joined
Jun 19, 2009
Messages
88
Hi! Google isn't helping much with this problem no matter how hard I look.

Ok. I have a form I am making to record changes we make to our regular employee travel bookings each month - and technically it will be four forms (one for Air Travel changes, Hotel changes, Rental changes, and Limo/Taxi changes - since they all have unique information). What I want to do for each form is use the check boxes I have in each to "open" the corresponding sections.

For example, on the Hotel Changes form there are 3 check boxes:
New Booking?
Changed Booking?
Canceled Booking?

The 'New Booking' check box does not need to "open" anything because no matter what happens, there will obviously be text-boxes there for the information (be it new or original bookings) - however the canceled booking check box should "open" a 'Canceled Reason' text-box, and the 'Changed Booking' check box should "open" up space for the new hotel name, check in and out dates/times, confirmation, and the reason for the change.

I keep using "open" with quotations because I am unsure exactly how to go about this. I have read that you can use text boxes to make invisible text boxes visible or to use check boxes to make sub forms visible... but I cannot get any of the coding I have found online to work.

I'm almost certain that the Sub Form method is the way to go due to its "Can Shrink" property that has worked really well for me before - but I don't know if that would even play a part in this...

Any and all help is welcome! Thanks in advance for any input!
 
What is the value of retaining information on a cancelled booking?
I would not handle a changed booking this way. I would cancel the original booking and then create a new booking.

To change the visibility, or enabled status--which I prefer, of a control while handling an event that occured for another control, use code like...
Code:
Private Sub chk_Click()
  [COLOR="Green"]'the enabled state of the textbox is determined by the checkbox's value[/COLOR]
  Me.tbSomeTextBox.Enabled = Me.chk
End Sub
 
What is the value of retaining information on a cancelled booking?
I would not handle a changed booking this way. I would cancel the original booking and then create a new booking.

To change the visibility, or enabled status--which I prefer, of a control while handling an event that occured for another control, use code like...
Code:
Private Sub chk_Click()
  [COLOR=Green]'the enabled state of the textbox is determined by the checkbox's value[/COLOR]
  Me.tbSomeTextBox.Enabled = Me.chk
End Sub

We make changes rather than cancellations because it is cheaper for our company. We are trying to cut down on costs, and changing tickets rather than canceling and re-booking them is way more cost efficient - and even more time efficient.

As for the code you provided you lost me...

If my check box [CanceledHotel] is = Yes, then I want the textbox [CancelHotelReason] to become visible (with its label as well... [CancelHotelReason_Label])

Where would your code go? In the VB Code editor? Isn't there a way to do it on the "On Update" of the check box --- but that would only work for the canceled check box because the changed text box must make more than one other text box visible...
 
I'm not saying to not change bookings in the real world. Your description of a changed booking in respect to your data is that you make visible a new set of textboxes for hotel name, etc... but what if the booking changes again? Your design can't handle this case. Instead, handle a changed booking by marking the original record as changed and now leave that data alone. Now create a new record with the data for the new (changed) booking. You can even store the ID of the record from which the change was made for easy reference or navigation. This will be a much more robust solution.

No sure how to make the code simpler. There is only one line!
Code:
Private Sub chkCancelledHotel_Click()
[COLOR="Green"]  'This routine handles a click event on the chkCancelledHotel checkbox.
  'If this code is on the same form as a checkbox named chkCancelledHotel and
  'chkCancelledHotel.OnClick = "[Event Procedure]" then
  'this code will run when that item is clicked.

  'This routine controls the enabled status of a textbox named tbReason where...
  'If checkbox = true then textbox.enabled = true, and...
  'If checkbox = false then textbox.enabled = false, therefore...
  'textbox.enabled = checkbox
[/COLOR]  Me.tbReason.Enabled = Me.chkCancelledHotel
End Sub
 
I have it working.

At first I entered the code and rather than being invisible it only made it disabled so I went back and switched out .Enabled with .Visible and it worked :D

Thanks for the help!
 

Users who are viewing this thread

Back
Top Bottom