Results 1 to 6 of 6
  1. #1
    djclinton15 is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Nov 2015
    Posts
    123

    How to open a Form to a Last Record

    Hi, I have a Form based on 2-qrys. I would like the Form to the Last Record. I tried this code, but it isn't seeming to be




    working:


    Private Sub Form_Load()
    DoCmd.GoToRecord , , acLastRec
    End Sub


    Any advise/suggestions will be greatly appreciated! Thanks in advanced.

  2. #2
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Try
    Code:
    Private Sub Form_Load()
      DoCmd.GoToRecord , , acLast
    End Sub

  3. #3
    djclinton15 is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Nov 2015
    Posts
    123
    First, thanks for responding to my thread. Unfortunately, The Code you provided didn't work. I received a 'Compile error' & 'Syntax error' message ...? Might you have any other suggestions?

  4. #4
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    In the attached dB, open the form "FirstRecForm". It should open with the first record selected (ID = 1).

    Close "FirstRecForm".

    Open "LastRecForm". It should open with the last record selected (ID = 61).

    I received a 'Compile error' & 'Syntax error' message ...?
    First, check your spelling.
    Then ensure the syntax is correct.

    I copied the load event code from Post #2 and pasted it into the form module. I did not get any errors......

  5. #5
    djclinton15 is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Nov 2015
    Posts
    123
    Okay, thanks Steve! I was missing the, 'Option Explicit' of the code, which I don't think you included in the provided code. Please, no offense, I'm NOT a programmer & get completely lost with VBA world. Sometimes I ll get a code from someone/somewhere, but I don't realize it needs to go into one of the events (in the event tab) & it screws me up. Steve, I'm sorry & will be honest, to truly don't understand, 'Databases;' you need to know programming & I'm just not smart enough to know the "guts" of databases' designing. I may know the surface of databases & can come up with a lot of ideas on different things I want to do, but don't always have the comprehension on how to implement my ideas/plans. Sorry to keep you & thanks again! You guys here are, GREAT!

  6. #6
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    The top two lines of EVERY code module (form or standard) should be
    Code:
    Option Compare Database
    Option Explicit
    Option Explicit ensures all variables are declared.
    There is a setting in the IDE under TOOLS/Options/Editor tab.... Check the box that says "Require Variable Declaration". Any NEW module will have Option Explicit added automatically.

    I'm just not smart enough to know the "guts" of databases' designing
    I don't believe it is because you "are not smart enough". I think it is just inexperience. Years ago I was trying to teach myself Turbo Pascal (forerunner of Delphi). I knew IBM BASIC, GW BASIC, Apple BASIC, Apple Floating Point Basic, could read FORTRAN, COBAL, machine language and assembly ....but Turbo Pascal was kicking my hindquarters. After about 18 months (I did say I was teaching myself,,,,right??? and it was sporadic studying and I have other excuses ) I finally had a breakthrough!
    Pascal is a bottom up language! BASIC is (can be) top down (or Spaghetti code if you use Goto too much).

    The point is - don't give up. After enough time, you get more familiar with the structure of programming, it becomes easier to understand how to implement ideas in code. (I do a lot of thing in code that I should do in queries..... but I'm learning more about queries.


    Keep working on it.....

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

Similar Threads

  1. Replies: 10
    Last Post: 12-17-2014, 03:31 PM
  2. Replies: 4
    Last Post: 12-16-2014, 05:08 PM
  3. Replies: 2
    Last Post: 03-13-2013, 06:13 PM
  4. Replies: 3
    Last Post: 08-26-2012, 10:04 PM
  5. Replies: 1
    Last Post: 05-03-2012, 02:25 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