Show specific fields after selecting from a combo box

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to create a form that when I select a certain choice from a combo
box, that only certain fields in the underlying table are displayed in an
orderly, justified format in which to populate those fields with data. For
example: in the drop down combo box I choose Lab Coats, I need to display
the Date, TimeIn, TimeOut, Name, Size, and Officer fields. If I choose
Portable Radio from the combo box I need to display Date, TimeIn, TimeOut,
Name, Radio# and Officer.

Can this be done without having to write a bunch of code? If not, can
someone help me write the specific code that would make this happen because I
only do wizards and macros at this point.

Thanks
 
Hi,


Use a tab control (instead of your combo box), and place the desired
controls on the appropriate tab-pages of your choice. You may have to drag a
given "field" on many pages, so have the "list of fields" available to
simplify your job, and simply drag the "fields" , drop them on the
tab-pages, page per page. That should create the controls with less click.


Hoping it may help,
Vanderghast, Access MVP
 
Spectacular!!! Thank you!! This makes my job so much easier.

I do have another question now.....
I need to filter the records depending on which tab I currently have focus
on. I created an ID field that will default depending on which tab the
record is created on. When I try to do an advanced filter, it does filter
the data but for the entire form, not the individual tab. Is it possible to
filter by specific tab?

Thanks again!!
 
Hi,


Maybe, but probably too slow, and I assume you won't add any record through
that interface:

create a (borderless) subform for each tab-page; if you have 5 pages, that
will make 5 subforms, each subform having the required controls. In the
Record source of each of these sub-form, be sure to have a SQL statement::


SELECT * FROM myTable WHERE pageID=0

for the page0, rather than just myTable


and

SELECT * FROM myTable WHERE pageID=1

for page1, and so on.


Do not use any parent-child relation between the main form and each of these
sub-form, the subform are already "filtered" by the SQL statement in the
record source statement.


Sure, you understand that the subform with the WHRE pageID=0 in its record
source should be place on tab 0, and so on.


I assume you do not plan to add records through this disposition, since the
subform won't be aware of the records added after you opened the form. We
would need some VBA code to "synchronize" the recordsets of the subforms and
the recordset of the main form, which defeat our goal to not have any single
line of code to type.



Hoping it may help,
Vanderghast, Access MVP
 
Hi,


Another alternative could be to come back to your original idea of using a
combo box, and VBA code to "hide/unhide" the controls on the form
accordingly to the value in the combo box. But that requires to write VBA
code.


Vanderghast, Access MVP
 
Back
Top