Populate List Box - Simply w/VBA Code

  • Thread starter bhipwell via AccessMonster.com
  • Start date
B

bhipwell via AccessMonster.com

Need some ideas.

I have a list box from which our clients will be able to select which form
they want to preview or print. However, each client should only have
selections available that apply specifically to their company. For example:

Company A will require forms 1, 2, 3, 6 and 7
Company B will require forms 1, 6 and 7
Company C will require forms 4, 5 and 6

I have some code right now to handle a simple two form variation:

If Forms("Main").Controls("Form1Req") = "Yes" and Forms("Main").Controls
("Form2Req") = "No" Then
Me.ListBox.RowSource = "Form 1"
Else
If Forms("Main").Controls("Form1Req") = "No" and Forms("Main").Controls
("Form2Req") = "No" Then
Me.ListBox.RowSource = "Form 2"
Else
If Forms("Main").Controls("Form1Req") = "Yes" and Forms("Main").Controls
("Form2Req") = "Yes" Then
Me.ListBox.RowSource = "Form 1; Form 2"
Else

If I want to continually make available more forms, the coding will become
overwhelming as I would have to take into account every possible combination
(the math of 1x2x3x4x5 for 5 options). Anyway this could be simplified?

B
 
D

Douglas J. Steele

Create a table with two fields: one being the report to run and the other
being the company. Put the company id somewhere on the form (it doesn't have
to visible) and have the list box's RowSource use it as a criteria to limit
what's displayed.
 
B

bhipwell via AccessMonster.com

Thanks, I'll try some version of your suggestion. Just trying to avoid
coding the potential 300k different combinations.
 
Top