Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Populate Listbox based on a radio button selected 1

Status
Not open for further replies.

mxp346

MIS
Apr 27, 2002
50
0
0
US
I have done some VB programming with Excel previously but never with Access.

I have a form with the following:

Radio Buttons Domestic and Overseas
Listbox Organization

I have a table called Organizations which has two columns (Organization and Location)

When a user clicks the radio button Domestic I would like the listbox to be populated with just Organizations where the Location = Domestic. Also, the same situation if a user clicks Overseas.

Can someone point me in the right direction?

Thank you very much.
 
If you have ever done this in Excel, it is 4.5 time easier in Access.

Assumptions:[ol]
[li]Radio buttons are contained in Frame '[tt]fraLocation[/tt]' and have the values Dometic=1 and Overseas=2.[/li]
[li]Listbox '[tt]lbOrganization[/tt]' shows only Organization and loads both Domestic and Overseas when the form loads [tt](lbOrganization.RowSource = SELECT Organization FROM tblOrganization;)[/tt][/li][/ol]
Place the following code in the [tt]Click()[/tt] event for [tt]fraLocation[/tt]
Code:
Select Case Me.fraLocation.Value
  Case 1
    Me.lbOrganization.RowSource = "SELECT Organization FROM tblOrganization WHERE Location='Domestic';"
  Case 2
    Me.lbOrganization.RowSource = "SELECT Organization FROM tblOrganization WHERE Location='Overseas';"
  Case Else
    Me.lbOrganization.RowSource = "SELECT Organization FROM tblOrganization;"
  End Select
Hope this gets you moving in the right direction.

CMP

Instant programmer, just add coffee.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top