Results 1 to 10 of 10
  1. #1
    Delta729 is offline Advanced Beginner
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Nov 2010
    Location
    Los Angeles
    Posts
    95

    Is it possible have button with vba to auto select item from combobox

    I hope this makes sense to you all. Still pretty much a complete novice here. (I'm learning really slow)

    I have a form with a combobox called cboClientNo. When this is selected, it filled in the cboClientName automatically with column code. It then cascades to the related cboMatterNo and cboMatterName. This all works fine.

    The thing I'm attempting to do is have a button, that when selected will fill in the cboClintNo or autoselect it possibly. I tried to insert a separate text box that has a dlookup for the correct client ID. This works. And then have the value = the cboClientNo = the value of this txtbox, which is where it "seems" to stop working. I'm thinking this just isn't possible, or I'm going at this completely wrong.

    Any help would be greatly appreciated.

    Thanks

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    I don't understand. If combobox is BOUND it should display value from record.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Delta729 is offline Advanced Beginner
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Nov 2010
    Location
    Los Angeles
    Posts
    95
    The combo box is bound and does display the records. What I'm trying to do is have a button that automatically selects one of the records. Click button and have "06000" selected from the combobox.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    But why? This would change the value in field the combobox is bound to. Do you want to change data?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    Delta729 is offline Advanced Beginner
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Nov 2010
    Location
    Los Angeles
    Posts
    95
    I don't want to change data, I'm trying to auto select data with a button. (This is why I'm asking if this is possible). Basically, I work at a law firm in a department that does tons on projects that we log into a database. We do a lot of work for tenants in the building as well, and they are all grouped into client number "0600 ". I'm trying to have a button that when selected will select their number and still have the other combo boxes still work correctly.

    There are several other items that need to be changed as well for the tenants than someone that works for our firm. I can do those updates through vba easy enough. I thought it would be nice to click a button to select and make all the changes at one time.

    If this is just a bad or not a good idea, that's fine, just let me know.

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    I am still confused. Combobox is bound to field. Programmatically setting value of combobox changes data in field.

    Not sure what you mean by 'make all the changes at one time'.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    Delta729 is offline Advanced Beginner
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Nov 2010
    Location
    Los Angeles
    Posts
    95
    All the changes are hiding certain form fields and auto populating text in other fields. But this basically sounds like it won't work.
    Thanks,

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    I don't know since I don't understand what you are trying to accomplish.

    If what you want to do is find existing records, i.e., filter the form or move to a specific record, that is doable.

    Code can certainly hide and populate controls.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    Delta729 is offline Advanced Beginner
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Nov 2010
    Location
    Los Angeles
    Posts
    95
    I got the answer. I was probably just not explaining the correctly, like I said early on - I'm a complete novice.

    Private Sub cmdTenant_Click()
    Me.cboClientNo.Value = "06000"
    call cboClientNo_AfterUpdate
    End Sub

    Thanks June7

  10. #10
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    So you are changing data - if the focus is on an existing record and combobox really is bound to field.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 1
    Last Post: 02-01-2015, 12:16 AM
  2. Replies: 3
    Last Post: 11-05-2014, 09:20 AM
  3. Replies: 1
    Last Post: 04-21-2014, 11:29 AM
  4. Replies: 7
    Last Post: 01-09-2014, 09:52 AM
  5. Selecting a combobox item with VBA
    By tylerg11 in forum Forms
    Replies: 6
    Last Post: 04-19-2012, 12:30 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