Populate List Box - Simply w/VBA Code

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

-- 
Message posted via http://www.accessmonster.com

0
bhipwell
7/18/2007 5:52:03 PM
access.forms 6864 articles. 2 followers. Follow

2 Replies
2763 Views

Similar Articles

[PageSpeed] 51

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.

-- 
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"bhipwell via AccessMonster.com" <u30281@uwe> wrote in message 
news:755de8f01166f@uwe...
> 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
>
> -- 
> Message posted via http://www.accessmonster.com
> 


0
Douglas
7/18/2007 8:50:16 PM
Thanks, I'll try some version of your suggestion.  Just trying to avoid
coding the potential 300k different combinations.

-- 
Message posted via http://www.accessmonster.com

0
bhipwell
7/19/2007 5:52:22 PM
Reply:

Similar Artilces:

How do I protect Visual Basic for Application Code
I have noticed that MS's templates and other Excel files received from other sources needs a password to open the VBA source code. I have been unable to find any assistance from OLH or figure it out on m,y own how to protect my VBA source code. Any help appreciated. Open excel open your workbook hit alt-f11 (to get to the vbe) hit ctrl-r (to see the project explorer) with your project selected in the project explorer Tools VBAProject Properties Protection tab. Zagrijs Venter wrote: > > I have noticed that MS's templates and other Excel files received from other > so...

Hide "All Disabled Accounts" from Exchange address list. #2
I'm trying to remove ex-employees names from the global address list in Exchange. The ex-employees accounts are disabled and many have been selected to "Hide from Exchange address list," but there are still a bunch of disabled accounts with active names in the global address list. Is there some action or query I can run to select "Hide from exchange address list" on all disabled accounts? Doing this one by one would be a total pain. Thanks Hi you can do this by using vbscript together with some LDAP filter but you could also use a tool (ADModify for example) that hel...

POPULATE CELL
I NEED TO HAVE A DROP DOWN WINDOW IN CELL A1 TO POPULATE A LIST TO B1, B2,B3 AND B4 Please drop the CAPS and describe what you mean by "populate a list" What type of choices would you have in the A1 dropdown and how would that determine what goes into B1:B4 Where does(do) the B1:B4 list(s) originate? Gord Dibben MS Excel MVP On Fri, 15 Feb 2008 20:02:01 -0800, ELBERT <ELBERT@discussions.microsoft.com> wrote: >I NEED TO HAVE A DROP DOWN WINDOW IN CELL A1 TO POPULATE A LIST TO B1, B2,B3 >AND B4 First, name the cells B1 to B4 : by selecting B1 to B4 and g...

How to create multiple subfolders using VBA
Hello and thanks for reading my question. I need some VBA programming help. I have a main folder with subfolders in it. I want to add a new subfolder to each subfolder in the directory. It would look something like this Main Folder Subfolder1 NewSubfolder Subfolder2 NewSubfolder Subfolder3 NewSubfolder Subfolder4 NewSubfolder I was able to use this VBA to do it for one folder, but I need it to look through all Subfolders MkDir ("C:\MainFolder\Subfolder1\Subfolder1.1") How do I look through each subfolder and add a new subfolder under each...

non vba way to print non continuous ranges
Hi, Is there a non vba way to print non continous ranges on the one shee using excel? Specifically, lets say I want to print data from columns A, B, C, G an K down to row 35 in each column. Is there a way I can do that withou manually making them continuous by cutting and pasting each range ont a new sheet? Regards, David Obei -- DavidObei ----------------------------------------------------------------------- DavidObeid's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=223 View this thread: http://www.excelforum.com/showthread.php?threadid=27196 You can h...

Help needed with Vlookup code
I have noticed other vlookup codes in excel and after looking at them have started to try and use them myself. 2 questions. 1) The codes i saw had a lot of $ signs in them. I dont use them when i use vlookup and it seems to work fine. Is there a reason $ signs are added? 2) I have a vlookup code "=VLOOKUP(A9,Database!A1:F8000,2,FALSE)" and so on for a few lines and when it finds a blank box it puts 0 in there to represent that. Is there a way i can have it so that instead of putting a zero in it just leaves the box blank? -- Help Needed -------------------------------------...

Add GL Distribution code to Check Stub in Payables Management
I have a customer that uses the Check Stub Top and Bottom for Payables Management and they would like to add the GL code for the transaction to the bottom stub only. We cannot seem to be able to link a table to the check stub top and bottom that has the GL code from the transactions. Any ideas? Thanks in advance. -- Tammy Chavez Mekorma MICR has this capability. -- Charles Allen, MVP "Tammy Chavez" wrote: > I have a customer that uses the Check Stub Top and Bottom for Payables > Management and they would like to add the GL code for the transaction to the > bo...

Bar Code
I'm opening a new retail business and would like to use the Manufactures bar code on many of my items......but for the life of me I can't figure out how to load the information into my system. I've serched the HELP screens, but no answers. I'm desperate - Can anyone guide me on how to do this? Sincere, thanks to anyone who can help :) Monica If using the UPC as your ILC doesn't work, you can add the UPC codes to the Alias tab of the Item Properties. Then if you're searching for WIDGET you don't need to memorize the UPC codes. HTH, Tom "Monica" ...

Using Access form to assign values of variables in an Excel VBA program
I have created a VBA program for Ms Excel.But,to get desired results, every time, I go into the code to change the values of variables.Is there a way to get the values of variables stored in an Access table? YOu need to do a search for ADO method (ActiveX Data Object). There are plenty of example of code on the web. You need to add two references in your VBA to use the method. from VBA menu tools - References 1) Microsoft Access XX.X object library 2) Microsfot ActiveX Data Objects X.X library Use the latest versio of the two libraries on your PC. You will make a conn...

Re: VBA coding
Reply meant for another post -- Don Guillett SalesAid Software donaldb@281.com "Don Guillett" <donaldb@281.com> wrote in message news:... > right click on sheet tab>view code>insert this>save. > Now, when you enter anything in column F (6) a row will be inserted > > Private Sub Worksheet_Change(ByVal Target As Range) > If Target.Column = 6 Then Target.EntireRow.Insert > End Sub > > > -- > Don Guillett > SalesAid Software > donaldb@281.com > "Nadeem Shafiullah" <nadeem57@telus.net> wrote in message > news:%23k...

How do i number a list of data in excel 2003?
I was shown once, but I can't remember how it was done. I have a list of 5000 things and I need to number then 1-5000, but don't want to go through all 5000. I have seen it done where you type the first few like 1-7 and then use a shortcut and drag it down the rest of the list and the numbers will populate. Please help! You can try something like this: =IF(B1="","",COUNTA($B$1:B1) copy down....or if there are no gabs in your list simply double click on the lower right corner of the cell. HTH JG -- pinmaster -------------------------------------------------...

mailing list servers for Exchange 2000/2003?
Are there any decent majordomo/listserv servers that integrate with Windows 2003 and Exchange 2000/2003? Try http://www.ikakura.com "Robert Gordon" <Robert_Gordon@nospam.perlegen.com> wrote in message news:#X1spgS5DHA.1368@TK2MSFTNGP10.phx.gbl... > Are there any decent majordomo/listserv servers that integrate with Windows > 2003 and Exchange 2000/2003? > > ...

Distribution List Troubleshooting
I have a distribution list that I created - the list works when I type in each individual's email address separately in the "to" field. It also works when I send to each person separately. BUT when I try to use the list, only some of the addresses receive the message - others come back undeliverable host. I have deleted and recreated this list three times already, and still the same result. HELP!!!!! ...

White List
How do I create a white list (do not filter) including people who are not in my global lists? Even the smallest list in Outlook 2000 doesn't fit on the exchange server if I try to set it to Stop Processing in the Rules Wizard. Even if it only happened after it went through the server it would be better than nothing. You can whitelist by defining a rule, like: Apply this rule after a message arrives sender is in <contacts> Address Book and on this machine only stop processing more rules <duplicate of above rule for each contact-type folder> Apply...

Using dial-up w/ citibank
Does credit card validation w/ citibank on a dial-up connection required that I get an Internet Service provider, or does the software simply call an 800 number out the modem when doing credit card authorizations? Thanks - Bob The answer depends on your configuration. I'd be happy to speak with you. I can be reached at 949-629-3002 during the day Pacific Time. Brett "Bob (new user)" wrote: > Does credit card validation w/ citibank on a dial-up connection required that > I get an Internet Service provider, or does the software simply call an 800 > number out t...

Message Boxes
When displaying a message box how do you insert rows, carriage returns and place bullit points on left hand side of box. I've seen how to do it somewhere and I know it's dead simple but can't remember where!!! Thanx all!!! Mikey, Use the concatenate operator, &, with the Chr(10) (line feed) code: MsgBox "First line" & chr(10) & "Second line" To keep the code cleaner-looking, you may want to use the form: MsgBox "This is the first line" & Chr(10) & _ "This is the second" & Chr(10) & _ "And the fina...

HOWTO: Bulk change "Hide from Exchange address lists" under "Exchange Advanced" using ADModify or VBScript
Using ADModify: (http://www.gotdotnet.com/workspaces/releases/viewuploads.aspx?id=f5cbbfa9-e46b-4a7a-8ed8-3e44523f32e2) 1. Select the CUSTOM tab 2. Check Box "Make a customized attribute modification" 3. Attribute Name field, enter "msExchHideFromAddressLists" (without quotes) 4. Attribute Value field, enter "TRUE" to Hide from lists, "FALSE" to show in lists (again, without quotes) 5. Hit Go! ----------------------------------------------------------------------- Using VBScript: (http://www.microsoft.com/technet/scriptcenter/resources/qanda/oct05/hey...

Item Code
Hi, In Item listing in Smartlist, I found a column for Item Code. This is distinct from Item Number and I could not find this in any menu, report or input screen. Maybe I am not seeing well enough. Does any one know the functionality of Item code while we already have Item number? Thanks CarlG My understanding is that the Item Code field is not currently being used and is planned to be used for international (non-US) versions of the software. "CarlG" wrote: > Hi, > > In Item listing in Smartlist, I found a column for Item Code. This is > distinct from Item Num...

Function VBA
Dear expert, I am not good at function VBA, but I know that can help me to save a lot of memory. Say a cell in K10, L10 and M10 Contain figures 7,8,10 How can I write a function say in J10 type =cross(K10,L10,M10) Outcome can be 4. If And(M10>L10, L10>K10) = Show "All DOWN" If And(K10>L10, L10>M10) = Show "All UP" If And(K10>L10, L10<M10) = Show "K cross L UP" If And(K10<L10, L10>M10) = Show "K cross L down" Now I have a lengthy function in J10 which is going to copy from J10 to J32000 =IF(AND(K10>L10,L10&g...

Create chart from List Box
How do I use a List Box, with the months in it, allowing the user to click on a month and pull up that particular chart? Do I have to create several charts and use the list box as a hyperlink or can I have the chart create itself? TIA, Brenda Jon Peltier has instructions on his web site that may help you: http://www.geocities.com/jonpeltier/Excel/Charts/ChartByControl.html Brenda wrote: > How do I use a List Box, with the months in it, allowing > the user to click on a month and pull up that particular > chart? Do I have to create several charts and use the > list b...

Access Coding from 2003 to 2007
Is there an easy way to find conversion code from Access 2003 to Access 2007 we are currently in the conversion process but not all of our coding is working how we need it to. They all worked in 2003 properly. What's not working? It should be relatively straightforward if you have used only the core libraries (VBA, Access, and DAO), your database is in a trusted location, and you are not too tied to menus/toolbars Generic conversion info: http://allenbrowne.com/Access2007.html -- Allen Browne - Microsoft MVP. Perth, Western Australia Tips for Access users - ht...

Changing Yes/no box to combo box
I have a table that contains a field that is the data type Yes/no. Instead of having the traditional checkbox I am opting for the combo box. I have changed the display control to Combo box however when i go to add this to my form it does not have a drop down with yes or no....I know there is something little i must be missing. Another question is if i change it to this type of design is my code still going to be if me.xxx = True Then.....or will it change to if me.xxx = -1 Then? Thanks for your help as all my database just utilize the checkbox yes/no feature and not the combo box fe...

Enable Combo box based on value in check box and list box....
I am working in Excel 2003 As a part of my worksheet titled "Worksheet" I am trying to enable Combo boxes based on the value of a check box and the value in a list box. There will be a total of 6 combo boxes on the Worksheet. The first combo box that deals with the body of a book will by default enabled. The second combo box will be set to appear disabled unless a forms control check box is checked to indicate there will be a cover on the book. The 3rd through 6th combo box will each be disabled by default and will be enabled when the list box which indicates the additional sect...

VBA Macro: Word 2003 (FormFields)
Hi, I have a question on how to capture a hyperlink that is inserted behind a checked FormField (type Checkbox). The idea is to create some sort of index page with checkboxes, which will summarize a number of hyperlinks (which point towards several files on the company network). A button will print out all of the CHECKED checkboxes. I'm not able to achieve this. This is my code so far: Private Sub PrintButton_Click() For x = 1 To ActiveDocument.FormFields.Count If ActiveDocument.FormFields(x).Type = wdFieldFormCheckBox Then If ActiveDocume...

Printing w/o text boxes
Is it possible to set up individual sheets to print without the text boxes included? We have instructions that we would like not to print. Select the area(s) you do want to print and then go File>Print Area>Set Print Area when you save this information will remain with the file. "GJR3599" wrote: > Is it possible to set up individual sheets to print without the text boxes > included? We have instructions that we would like not to print. Select your text boxes. If you have lots & lots of them, you can do this quickly by pressing the F5 key, clicking on the Spec...