Results 1 to 3 of 3
  1. #1
    behnam is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2014
    Posts
    72

    How to open form and go to record with certain ID.

    Hi guys,

    I know how to open a form, but it automatically goes to the first record. Can someone help me with the vba code to not only open a form (called form1) but takes me to the record with the same ID value as the number stored in a variable called numstor.



    Thanks for your help.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    The form has a query set in the RECORDSOURCE property. (use the wizard to build an instant form..it will attach the table/query)
    Under TOOLS, STARTUP, put your form name to open as the db opens. It will open to the 1st record.

    If you want to go to a record, put a box on the form (be sure to view the NAME of the txt box for the code below..ie txtBoxID)
    after update event would be:

    Code:
      'text box afterupdate
    me.filter ="[numstor] = " & txtBoxID
    me.filteron = true

  3. #3
    NTC is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2009
    Posts
    2,392
    another quite simple and common approach is that the form being opened has a record source that is a query; and this query has criteria for numstor

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

Similar Threads

  1. Replies: 3
    Last Post: 11-01-2013, 10:16 AM
  2. Replies: 2
    Last Post: 03-13-2013, 06:13 PM
  3. Replies: 3
    Last Post: 08-26-2012, 10:04 PM
  4. Replies: 1
    Last Post: 05-03-2012, 02:25 PM
  5. If record does not exist, open add new record form
    By RobertIngles in forum Programming
    Replies: 2
    Last Post: 02-01-2011, 08:47 AM

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