0
votes

i'm pretty newbie in Access VBA

I'm developing an some access forms for Bussiness car control where users makes requests to use a car.

In the request there will be a combo box where the user have to select how many passangers will be using the car and text boxes to input their name and a phone number.The company can provide Microvans or Vans if the user needs.

My question is how can i add more text boxes according to the number of passengers the user selects? Also i need the text boxes linked to the DB fields for passenger info (I already have all the fields needed in the DB)

I already made some invisible text boxes but as i need many of them the form will become too big fo those user that need only one text box.

Am i doing something too crazy?

1
Yes. If the form isn't too big for those with several passengers, how can it be too big for none? The "invisible" approach is quite simple and effective.Gustav
But if i put say 10 text boxes one under another and make them invisible the form will become big and will have a big blank space right? or is there any way to hide the boes?Ookami

1 Answers

0
votes

When using static userforms, and having textboxes have been set as visible = False, you must ensure that there is enough space for all textboxes to show, should the form require them to turn visible = True.

You can create dynamic userforms; as a greater number of passengers are selected, the form will extend down whilst adding the additional textboxes. It's weighing up whether the development time, and future maintenance time, is worth the form being dynamic in this way. It can get complex and be difficult to maintain in the long run.

I would recommend, instead of having a combobox where they select how many passengers, there is instead 2 buttons '+' and '-', and between these 2 buttons you will have a label which shows the number of passengers. The label increases or decereases, dependant on which button is pressed. This way each time they press to increase passengers, it increases the label and adds an additional textbox. There is an article here which may help if you need ideas on the code this requires: Dynamic Userforms