Results 1 to 6 of 6
  1. #1
    cgclower is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jul 2011
    Posts
    6

    Go to a record that is in a combobox

    OK, I know I am close on this one, just can’t seem to find exactly the right code to make it work.



    I have a form with a combo box that displays the names of customers from the tblCustomers table. Beside that I have a button that opens a split form of the tblCustomers table so the user can edit the table if they wish.

    When clicking the button to open the split form, I would like the record that was last selected in the combo box to be the one highlighted in the split form. I am trying to use GoToRecord, but can’t seem to make it work.

    Code:
     
    Private Sub Form_Load()
     
        DoCmd.GoToRecord  ,  ,  acGoTo,  [what goes here?]
     
    End Sub
    I need to somehow get the value of the combo box and put it at the end of the GoToRecord command…but how?

    Thanks for the help!

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Easier alternative to GoToRecord is to filter the opening form to specific record using the WHERE CONDITION argument of OpenForm in the button Click event:

    DoCmd.OpenForm "form name here", , , "CustomerID=" & Me.comboboxname
    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
    cgclower is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jul 2011
    Posts
    6
    Thanks for the tip! I thought about that too, but doing that only gets me the records that match the WHERE condition. I would like ALL the records in the table to be displayed, but the "current" one (the one displayed in the combobox) to be pre-selected in the split form.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    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
    HiTechCoach's Avatar
    HiTechCoach is offline MS MVP - Access Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jul 2010
    Location
    Oklahoma, USA
    Posts
    705
    Oops wrong thread.

  6. #6
    cgclower is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jul 2011
    Posts
    6

    Solved!

    Thanks everyone for the help! Here is the code I ended up using:

    Code:
     
    DoCmd.FindRecord DLookup("Name", "tblCustomers", "CustomerID = " & Forms!frmContracts!CustID.Value & ""), , True, , True
    Thanks again for the tips, you guys rock!

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

Similar Threads

  1. Combobox selection updates Table record
    By lucky in forum Access
    Replies: 4
    Last Post: 10-30-2011, 10:44 AM
  2. Replies: 8
    Last Post: 06-22-2011, 10:51 AM
  3. Replies: 9
    Last Post: 12-18-2010, 12:51 PM
  4. Replies: 0
    Last Post: 08-24-2010, 06:38 PM
  5. Replies: 0
    Last Post: 12-16-2009, 01:14 PM

Tags for this Thread

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