Combox Box -Help Please

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shimul
    New Member
    • Nov 2008
    • 28

    Combox Box -Help Please

    Hello There,

    I have combo box and getting data from table.

    I wanna read data from combo box and auto fill the text box when form open or load.

    For Example:

    Combo have three value a;b;c and wanna display a,b,c in text box (Continuous Forms) when open or load the form.

    Is it possible? If so, Can you please help me to do it?

    Thank you in Advance.
  • DonRayner
    Recognized Expert Contributor
    • Sep 2008
    • 489

    #2
    OK, a few assumptions here,

    1. You are using two forms
    2. Combo box on the first form
    3. Textbox on the 2nd form

    In the on open event for the 2nd form you would place code along these lines. You will need to substitute MyTextBox, 1stFormName and ListBoxName with the actual names from your project.

    Code:
    Me.MyTextBox = Forms!1stFromName.Form!ListBoxName

    Comment

    • shimul
      New Member
      • Nov 2008
      • 28

      #3
      Thank you for your reply.

      My combobox and textbox in the same form.

      Another question:

      Have table with data ( like a,b,c,d in column 1), want to read data from table and put in text box in continuous form.

      like tble name "tbltest" and textbox name "txtbox".

      now want to read first data from table and put in text box, then read second one and put in text box .....so on unit finish data in table.

      Try to write following code, but couldn't fiqure out ----" New in VBA"
      Code:
      Set db = CurrentDb()
      Set rsLoc = db.OpenRecordset("tbltest", DB_OPEN_TABLE)
      'Loop through records
      rsLoc.MoveFirst
      While Not rsLoc.EOF
      
      txtbox =
      Thx

      *Please check attachment*
      Attached Files
      Last edited by NeoPa; Apr 4 '09, 09:19 AM. Reason: Please use the [CODE] tags provided

      Comment

      • DonRayner
        Recognized Expert Contributor
        • Sep 2008
        • 489

        #4
        Hi shimul,

        If they are on the same form then the code would be. And you would place it in the after update event for your listbox.

        Code:
        Me.MyTextBox = Me.ListBoxName
        As for your other question, I see that you have already asked it in another post so that's where I'll post back.

        Comment

        • NeoPa
          Recognized Expert Moderator MVP
          • Oct 2006
          • 32634

          #5
          Originally posted by shimul
          I have combo box and getting data from table.

          I wanna read data from combo box and auto fill the text box when form open or load.
          There are two possibilities here :
          1. The data you want to display is also in your Record Source (table or query). Solution is easy. You bind the TextBox control to the Field you want.
          2. The data is not available and you want it to reflect a value dependent on the value of the ComboBox control. IMPOSSIBLE.

          You're struggling with this because it is the latter I expect. An unbound control on a continuous form can only ever store one item at a time. As it is not a bound control it is not perpetuated across the various records but is a single, form level item.

          Comment

          Working...