Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

How to store multiple variables from a combo box selection

Discussion in 'Information Technology' started by maciasm@gmail.com, Jul 28, 2006.

  1. maciasm@gmail.com

    maciasm@gmail.com
    Expand Collapse
    Guest

    I have a form that is using combo box selections to create a query for
    a large table. I need to use two items from the 1st combo box to
    create the query, but can only figure out how to use one. "Name" is
    used to display a station name to the user, while "MaintSched "is used
    as an afterupdate for the next combo box. I use "Me.txtStation" (shown
    below) to include the correct "MaintSched" value in the next query.
    How could I save "StationID" as a variable for use in a later query?

    SELECT tblSystem.StationID, tblSystem.MaintSched, tblSystem.Name
    FROM tblSystem;

    Me.txtSubsystem.RowSource = _
    " SELECT ID, SubSystem, MaintSchedule" & _
    " FROM tblSubsystems" & _
    " WHERE MaintSchedule = " & Me.txtStation & _
    " ORDER BY SubSystem"
     
  2. Loading...

    Similar Threads Forum Date
    Heritage Private Firm Engaged to Restore Interiors of Harmandar Sahib History of Sikhism Nov 16, 2013
    USA 2 Sikhs shot dead in US utility store Breaking News Sep 8, 2013
    UK Rare Set of Sikh Armour to be Restored Breaking News Aug 16, 2013
    SciTech Eternal Sunshine of the Bionic Mind: Prosthesis Could Restore Memory Breaking News Jun 24, 2013
    An American Turned Sikh to Restore Ancient Gurdwaras Sikh Gurdwaras Jan 10, 2013

  3. Mike Labosh

    Mike Labosh
    Expand Collapse
    Guest

    You must use a ListBox setup for multiselect, not a ComboBox.

    --


    Peace & happy computing,

    Mike Labosh, MCSD MCT
    Owner, vbSensei.Com

    "Escriba coda ergo sum." -- vbSensei


    <maciasm@gmail.com> wrote in message
    news:1150301570.571754.89560@y43g2000cwc.googlegroups.com...
    >I have a form that is using combo box selections to create a query for
    > a large table. I need to use two items from the 1st combo box to
    > create the query, but can only figure out how to use one. "Name" is
    > used to display a station name to the user, while "MaintSched "is used
    > as an afterupdate for the next combo box. I use "Me.txtStation" (shown
    > below) to include the correct "MaintSched" value in the next query.
    > How could I save "StationID" as a variable for use in a later query?
    >
    > SELECT tblSystem.StationID, tblSystem.MaintSched, tblSystem.Name
    > FROM tblSystem;
    >
    > Me.txtSubsystem.RowSource = _
    > " SELECT ID, SubSystem, MaintSchedule" & _
    > " FROM tblSubsystems" & _
    > " WHERE MaintSchedule = " & Me.txtStation & _
    > " ORDER BY SubSystem"
    >
     
  4. maciasm@gmail.com

    maciasm@gmail.com
    Expand Collapse
    Guest

    I'm actually trying to grab two values from the same selection. The
    selection I am making has 3 fields [stationID,MaintSched,Name]. I want
    to save both the stationID and MaintSched fields for later use.
    Currently I can only store one value as the 'Me' value in my combo box
    titled txtStation (Me.txtStation).

    Thank you for your help,

    Michael
    Mike Labosh wrote:
    > You must use a ListBox setup for multiselect, not a ComboBox.
    >
    > --
    >
    >
    > Peace & happy computing,
    >
    > Mike Labosh, MCSD MCT
    > Owner, vbSensei.Com
    >
    > "Escriba coda ergo sum." -- vbSensei
    >
    >
    > <maciasm@gmail.com> wrote in message
    > news:1150301570.571754.89560@y43g2000cwc.googlegroups.com...
    > >I have a form that is using combo box selections to create a query for
    > > a large table. I need to use two items from the 1st combo box to
    > > create the query, but can only figure out how to use one. "Name" is
    > > used to display a station name to the user, while "MaintSched "is used
    > > as an afterupdate for the next combo box. I use "Me.txtStation" (shown
    > > below) to include the correct "MaintSched" value in the next query.
    > > How could I save "StationID" as a variable for use in a later query?
    > >
    > > SELECT tblSystem.StationID, tblSystem.MaintSched, tblSystem.Name
    > > FROM tblSystem;
    > >
    > > Me.txtSubsystem.RowSource = _
    > > " SELECT ID, SubSystem, MaintSchedule" & _
    > > " FROM tblSubsystems" & _
    > > " WHERE MaintSchedule = " & Me.txtStation & _
    > > " ORDER BY SubSystem"
    > >
     
  5. Michael H

    Michael H
    Expand Collapse
    Guest

    Hi.

    If I understand correctly, you have a multicolumn ComboBox named txtStation,
    and want to retrieve values from two different columns for one selection.

    If this is the case, replace Me.txtStation with Me.txtStation.Column(x)
    where x is the number of the ComboBox column containing the data you want to
    retrieve, starting with 0 as the first column.

    So, if the columns appear in the order you listed them (stationID,
    MaintSched, Name), your WHERE line might look something like this (air code,
    and watch for line wrap):
    " WHERE MaintSchedule = " & Me.txtStation.Column(1) & " AND stationID = " &
    Me.txtStation.Column(0) & _


    -Michael


    "maciasm@gmail.com" wrote:

    > I'm actually trying to grab two values from the same selection. The
    > selection I am making has 3 fields [stationID,MaintSched,Name]. I want
    > to save both the stationID and MaintSched fields for later use.
    > Currently I can only store one value as the 'Me' value in my combo box
    > titled txtStation (Me.txtStation).
    >
    > Thank you for your help,
    >
    > Michael
    > Mike Labosh wrote:
    > > You must use a ListBox setup for multiselect, not a ComboBox.
    > >
    > > --
    > >
    > >
    > > Peace & happy computing,
    > >
    > > Mike Labosh, MCSD MCT
    > > Owner, vbSensei.Com
    > >
    > > "Escriba coda ergo sum." -- vbSensei
    > >
    > >
    > > <maciasm@gmail.com> wrote in message
    > > news:1150301570.571754.89560@y43g2000cwc.googlegroups.com...
    > > >I have a form that is using combo box selections to create a query for
    > > > a large table. I need to use two items from the 1st combo box to
    > > > create the query, but can only figure out how to use one. "Name" is
    > > > used to display a station name to the user, while "MaintSched "is used
    > > > as an afterupdate for the next combo box. I use "Me.txtStation" (shown
    > > > below) to include the correct "MaintSched" value in the next query.
    > > > How could I save "StationID" as a variable for use in a later query?
    > > >
    > > > SELECT tblSystem.StationID, tblSystem.MaintSched, tblSystem.Name
    > > > FROM tblSystem;
    > > >
    > > > Me.txtSubsystem.RowSource = _
    > > > " SELECT ID, SubSystem, MaintSchedule" & _
    > > > " FROM tblSubsystems" & _
    > > > " WHERE MaintSchedule = " & Me.txtStation & _
    > > > " ORDER BY SubSystem"
    > > >

    >
    >
     

Share This Page