Set variable from value in a table

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Remco Groot Beumer

    Set variable from value in a table

    Hello,

    I created a program in which I use modules and classmodules for setting my
    variables. For example when I need to set the customerID in a variable I use
    something like: Object.Variable s.Customers.Cus omerID = ....
    This works great and is similar in structure as for example the Docmd. or
    me. structure.

    Now I created a search form which can be opened from many forms, it consist
    of only a listbox. The listbox is filled at startup. All necesery data I
    keep in a table (row source, column withs etc). When I doubleclick on the
    listitem I want a variable to be set. Instead of creating a long If..then.
    structure, I want to keep the variables which needs to be set in my table.
    So now I have a value in a table, which represents my variable. Is there a
    way I can set the variable this way.

    For example: I have a record in the table for a cusomter search. When I
    doubleclick in the listbox I want the value in my table (which represents
    the variable) to be set. So in the table is
    "Object.Variabl es.Customers.Cu somerID" (as a value) and the listbox gives a
    customerID which needs to be matched to the
    Object.Variable s.Customers.Cus omerID variable.

    IS this possible???

    Thanx,

    Remco


  • MacDermott

    #2
    Re: Set variable from value in a table

    If I understand you correctly, I think many of us merely human Access
    programmers would do this:

    Assuming the data for your listbox is in a table named tblCustomer, and that
    it has (at least) two fields:
    CustomerID
    CustomerName

    Set the RowSource of your listbox like this:
    SELECT CustomerID,Cust omerName FROM tblCustomer

    Set the listbox's BoundColumn property to 1, its ColumnCount property to 2,
    and its ColumnWidths to 0;1.
    Now the listbox should display all of your CustomerNames in a list 1" wide.
    (If you want it a different width, change the second value in ColumnWidths.)
    When you click on an item in the listbox, the listbox's Value property will
    hold the value of the corresponding CustomerID, and be used in coding as
    MyListbox.Value . (Use the name of your listbox instead of MyListbox, of
    course.)

    HTH
    - Turtle

    "Remco Groot Beumer" <info@rgbplus.n l> wrote in message
    news:c0320u$iru $1@news3.tilbu1 .nb.home.nl...[color=blue]
    > Hello,
    >
    > I created a program in which I use modules and classmodules for setting my
    > variables. For example when I need to set the customerID in a variable I[/color]
    use[color=blue]
    > something like: Object.Variable s.Customers.Cus omerID = ....
    > This works great and is similar in structure as for example the Docmd. or
    > me. structure.
    >
    > Now I created a search form which can be opened from many forms, it[/color]
    consist[color=blue]
    > of only a listbox. The listbox is filled at startup. All necesery data I
    > keep in a table (row source, column withs etc). When I doubleclick on the
    > listitem I want a variable to be set. Instead of creating a long If..then.
    > structure, I want to keep the variables which needs to be set in my table.
    > So now I have a value in a table, which represents my variable. Is there a
    > way I can set the variable this way.
    >
    > For example: I have a record in the table for a cusomter search. When I
    > doubleclick in the listbox I want the value in my table (which represents
    > the variable) to be set. So in the table is
    > "Object.Variabl es.Customers.Cu somerID" (as a value) and the listbox gives[/color]
    a[color=blue]
    > customerID which needs to be matched to the
    > Object.Variable s.Customers.Cus omerID variable.
    >
    > IS this possible???
    >
    > Thanx,
    >
    > Remco
    >
    >[/color]


    Comment

    • Bas Cost Budde

      #3
      Re: Set variable from value in a table

      Remco Groot Beumer wrote:
      [color=blue]
      > Instead of creating a long If..then.
      > structure, I want to keep the variables which needs to be set in my table.
      > So now I have a value in a table, which represents my variable. Is there a
      > way I can set the variable this way.[/color]

      Maybe I don't understand the question correctly; but does the article
      'public variables' on my site provide any help?

      Especially the Click portion of the question is unclear to me. It may
      help if you mail me in Dutch?
      --
      Bas Cost Budde


      Comment

      Working...