Results 1 to 2 of 2
  1. #1
    noaccessguru is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    Melbourne, Australia
    Posts
    68

    Quick VBA Command Button code help :)

    Hi guys,



    I have a quick code question that I need some help with and it is the final piece of my puzzle


    I have a combo box where a user will select the Record (Auto Number ID) that they want to edit and I have a command button which will open a Form to edit the selected record.

    But say we have deleted records in between, and there is 11 records in the table but we are actually up to ‘Auto Number ID 15’, how do I write the code to open this ‘ID’ number, not the record?

    currently if I select ‘Auto Number ID’ 12 it is bringing back ‘RECORD’ 12, not the ID 12.

    Hope this makes sense? And any help appreciated!


    The current code I have on the Command Button is:

    Private Sub cmdEdit_Record_Click()

    Dim RecordID As Long

    RecordID = Me.cmbSelect_Record.Value

    DoCmd.OpenForm "Edit_Record"
    DoCmd.GoToRecord acDataForm, "Edit_Record", acGoTo, RecordID

    End Sub

    Me.cmbSelect_Record.Value gives the ID number of the record, but once a record gets deleted, this doesn’t match the recordID, therefore there is a mismatch in what it will open up.
    Last edited by noaccessguru; 10-01-2013 at 08:23 PM. Reason: added code info

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Simple Code for a Command Button
    By dvgef2 in forum Reports
    Replies: 5
    Last Post: 06-21-2013, 05:04 PM
  2. Command Button VBA Code
    By nyymattingly23 in forum Programming
    Replies: 13
    Last Post: 01-04-2013, 03:08 PM
  3. Command button code to clear form
    By windwardmi in forum Forms
    Replies: 15
    Last Post: 11-21-2010, 03:21 PM
  4. Form/report command button code
    By max3 in forum Forms
    Replies: 1
    Last Post: 08-26-2009, 02:18 AM
  5. Command button code
    By lfolger in forum Forms
    Replies: 3
    Last Post: 03-25-2008, 04:26 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