Results 1 to 6 of 6
  1. #1
    Join Date
    Jan 2005
    Posts
    18

    Unanswered: Listbox and Textbox help needed!

    I have 5 textboxes and a listbox on the same form.

    Both the textboxes and the listbox have the same query (qrytest) as their control source.

    The list box lists all the records in the query (5 Fields).

    How do I get the textboxes to display the fields I select from the listbox when I select a row from the listbox?

    I have tried forms!myform!text1 = mylstbox.colum(0) 1,2,3,4,5 etc but I keep getting error messagees.

    Any help ideas?

    Cheers!

  2. #2
    Join Date
    Sep 2004
    Posts
    2
    Try this:

    Set the text boxes with no control source.
    Instead of the query, insert a Dlookup function in each text box:

    =Dlookup("[name1 of the field of the query to show]";"Qrytest";"[Qrytest]![..ID]=![mylstbox]")
    =Dlookup("[name2 of the field of the query to show]";"Qrytest";"[Qrytest]![..ID]=![mylstbox]")
    .
    .
    =Dlookup("[name5 of the field of the query to show]";"Qrytest";"[Qrytest]![..ID]=![mylstbox]")


    Then add in the AfterUpdate Event (of the List):

    Text1.requery
    Text2.requery
    .
    .
    Text5.requery


    Good luck!

  3. #3
    Join Date
    Aug 2002
    Location
    Melbourne, Australia
    Posts
    111
    have a look at the attached sample.

    Is this what you want to do?
    Attached Files Attached Files
    Regards,



    John A

  4. #4
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    You must be newtoforums1 too, because its a no-no to mention that you are getting an error message and then not tell us what the message was.

    What error message do you get?
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  5. #5
    Join Date
    May 2004
    Location
    New York State
    Posts
    1,178
    How about copying and pasting your actual code? the line "Forms!myform!, etc." has at least two errors that I see right away.

    Sam

  6. #6
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926

    Listbox help

    Try:

    forms!myform!text1 = Forms!myform!mylstbox.colum(0)

    or

    forms!myform!text1 = Forms!myform!mylstbox

    or (the easiest way!)

    simply set the Control Source of the field: text1 to -

    =Forms!myform!mylstbox.column(0)

    or

    =Forms!myform!mylstbox (best way) - use this syntax as the Control Source of text1.

    Check which column in mylstbox you're using as the Bound Column. It's easiest to use the first column as your bound column and use the 2nd syntax in the examples above but it depends on your needs of the listbox and what values you want to show in text1.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •