Results 1 to 5 of 5
  1. #1
    Richie27 is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Feb 2012
    Location
    Ireland
    Posts
    159

    Populate a text box based on a combobox selection?

    Anyone any ideas?



    Thanks in advance.

    Rich.

  2. #2
    Richie27 is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Feb 2012
    Location
    Ireland
    Posts
    159
    I have this bit of code - not working though!! row in the brackets is a field in "qry_select_boxes", "su_box_location" is a table, box_ID is a field in that table and cboBox is the combo I'm trying to use as the id. The code does nothing though.

    Private Sub cboBox_Change()

    Dim row As String

    Me.cboBox.SetFocus
    row = DLookup("[row]", "qry_select_boxes", "su_box_location.box_ID=Me.cboBox")
    Me.txt_row.SetFocus
    Me.txt_row.Text = row



    End Sub

  3. #3
    R_Badger is offline Knows a few tricks
    Windows XP Access 2003
    Join Date
    Feb 2012
    Location
    Suffolk, UK
    Posts
    262
    Try:

    Private Sub cboBox_Change()

    Dim row As String

    Me.cboBox.SetFocus
    row = DLookup("[row]", "qry_select_boxes", "su_box_location.box_ID="&Me.cboBox)
    Me.txt_row.SetFocus
    Me.txt_row.Text = row
    End Sub

  4. #4
    Richie27 is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Feb 2012
    Location
    Ireland
    Posts
    159
    Quote Originally Posted by R_Badger View Post
    Try:

    Private Sub cboBox_Change()

    Dim row As String

    Me.cboBox.SetFocus
    row = DLookup("[row]", "qry_select_boxes", "su_box_location.box_ID="&Me.cboBox)
    Me.txt_row.SetFocus
    Me.txt_row.Text = row
    End Sub
    A bleeding ampersand!! I just don't believe it!! All morning gone because of a bleeding ampersand!!!

    Thanks a million!

    You are a life saver!

  5. #5
    Richie27 is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Feb 2012
    Location
    Ireland
    Posts
    159
    I now have a similar problem to the first one you resolved for me regarding the subCmbo/mainCmbo thing.

    The thing is now though that I need the text box populated using the code above to change when the combo on the main form has been changed, rather than just when the subform combo is changed. Does that make sense? Is there some kind of Requery thing I can use?

    thank s a million for the help you've given already!! Really appreciate it!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 09-06-2011, 01:47 PM
  2. Replies: 29
    Last Post: 08-16-2011, 05:52 PM
  3. Populate a field based on combobox selection
    By rscott7706 in forum Access
    Replies: 5
    Last Post: 06-02-2011, 03:18 PM
  4. Replies: 0
    Last Post: 08-24-2010, 06:38 PM
  5. Replies: 0
    Last Post: 12-16-2009, 01:14 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums