Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    Join Date
    Jun 2013
    Posts
    16

    Unanswered: How to Populate the Access Form Text Box With Combo box

    Please let me help by the administrator or any other experiences person that how to populate my access form text box with the help of combo box.
    i mean that when i pick a value from the combo box, all the correspondence data should be appear in the text field.
    I have already try the following method but the result is nothing.

    1.Open a table named "tableSource" with the fields of primary key,FirstName,LastName.And then filled it with necessary data.

    2. Open a 2nd table named "tablemain" with the same field of above to receive the record from the form.

    3. Make a One to One relation between these two table.

    4.Open a new form on the basis of 2nd table and put a combo box with data from the source table.

    5 . i click on the combo box event procedure and then click "on chage" and enter the code

    "me.txtFirstName.Value=me.cmbx.colmn(1)"

    "me.txtLastName.Value=me.cmbx.colmn(2)"

    All this procedure give me no result and my access form text field has not been populated.

    Please Clear It in details .

    Thanks
    Last edited by ionline; 11-30-13 at 09:53.

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    Provided that the second column of the combo contains the first names and the third column of the combo contains the last names, you should use:
    Code:
    Private Sub cmbx_AfterUpdate()
        Me.txtFirstName.Value=Me.cmbx.Column(1)
        Me.txtLastName.Value=Me.cmbx.column(2)
    End Sub
    Have a nice day!

  3. #3
    Join Date
    Jun 2013
    Posts
    16
    Quote Originally Posted by Sinndho View Post
    Provided that the second column of the combo contains the first names and the third column of the combo contains the last names, you should use:
    Code:
    Private Sub cmbx_AfterUpdate()
        Me.txtFirstName.Value=Me.cmbx.Column(1)
        Me.txtLastName.Value=Me.cmbx.column(2)
    End Sub
    Thanks for your comments.i use the above code and it work for the first time but when i close the form and ropen then it stops the work.please give me a little more help.Thanks

  4. #4
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    Place a breakpoint on the first line of the procedure cmbx_AfterUpdate() and see what happens when you select a row in the combo.
    Have a nice day!

  5. #5
    Join Date
    Jun 2013
    Posts
    16
    Quote Originally Posted by Sinndho View Post
    Place a breakpoint on the first line of the procedure cmbx_AfterUpdate() and see what happens when you select a row in the combo.
    i again thank you and sorry for my stupid question but i m novice in this field.So please don't mind about my boring questions.
    I m a little confuse about the "breakpoint".
    Will you explain a little more about the breakpoint i mean that what do u mean by a break point and where to palace it in my code.

    Thanks

  6. #6
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    Select the line where you want to place the breakpoint, then click in the left margin (see attached image).
    Attached Thumbnails Attached Thumbnails Breakpoint.jpg  
    Have a nice day!

  7. #7
    Join Date
    Jun 2013
    Posts
    16
    I have try my code according to your instruction.But when i click on the combo box ,suddenly it a pear the vba code window .And my code is fail agian.
    The screen shot is given below.
    Attached Thumbnails Attached Thumbnails debuging.JPG  

  8. #8
    Join Date
    Jun 2013
    Posts
    16
    I use exactly the following code for populating my text box with the help of combo box on the form.

    Private Sub cmbx_AfterUpdate()
    Me.txtFirstName.Value=Me.cmbx.Column(1)
    Me.txtLastName.Value=Me.cmbx.column(2)
    End Sub

    When i try to check my code,it work well.but when i close my form and reopen it.It fail to work and my text box show nothing according to the combo box.I also debug it but receive the same result.I have check everything one by one write the code again and again but still fail.I don't know where is the problem.Please give me every possible solution.

  9. #9
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    To see what the rows of the combo actually contain, try:
    Code:
    Private Sub cmbx_AfterUpdate()
    MsgBox "Col.1: " & Me.cmbx.Column(1) & " Col.2: " & Me.cmbx.column(2)
    Me.txtFirstName.Value=Me.cmbx.Column(1)
    Me.txtLastName.Value=Me.cmbx.column(2)
    End Sub
    Have a nice day!

  10. #10
    Join Date
    Jun 2013
    Posts
    16
    Quote Originally Posted by Sinndho View Post
    To see what the rows of the combo actually contain, try:
    Code:
    Private Sub cmbx_AfterUpdate()
    MsgBox "Col.1: " & Me.cmbx.Column(1) & " Col.2: " & Me.cmbx.column(2)
    Me.txtFirstName.Value=Me.cmbx.Column(1)
    Me.txtLastName.Value=Me.cmbx.column(2)
    End Sub
    Sorry to distrub you again but the problem is as it is.The msg box appear and the code working well on first attept.but when i close it and then reopen the code fail to work and no msg box apear.

  11. #11
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    Could be a corrupted database.
    - First make a backup of the database.
    - Then, try to compact and repair.
    - If it does not work, export the form in a text file:
    1. Close the form.
    2. Open a Standard Module.
    3. Open the Immediate Window (CTRL+G) and type:
    Code:
    Application.SaveAsText acForm, "FormName", "FormName.txt"
    - Then delete the form.
    - Then compact and repair the database.
    - Finally, re-import the form from its text file (see above) using:
    Code:
    Application.LoadFromText acForm, "FormName", "FormName.txt"
    If it's not too complex you could also delete and recreate the form.
    Have a nice day!

  12. #12
    Join Date
    Jun 2013
    Posts
    16

    Screen Shot

    I m posting a screen shot of access coding please check it in detail if you find any mistake point out it.because i m still fail to solve my problem.

    Thanks
    Attached Thumbnails Attached Thumbnails S.Shot.png  

  13. #13
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    Did you try what I suggested?
    Have a nice day!

  14. #14
    Join Date
    Jun 2013
    Posts
    16
    Quote Originally Posted by Sinndho View Post
    Did you try what I suggested?
    I m trying it Now

  15. #15
    Join Date
    Jun 2013
    Posts
    16
    I have delete all the old files and create a totally new file for experiment only .It also gives the same issue.I mean the code work only first time.And when i close and reopen it the code did not work the second time.

Posting Permissions

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