Results 1 to 5 of 5
  1. #1
    2 Star Lounger
    Join Date
    Apr 2001
    Location
    Des Moines, Iowa
    Posts
    180
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Auto-start Form at Last Record

    I've got a form currently opening to a new record automatically at startup using a small bit of VBA, of which I know nothing. Can anyone tell me what the Event Procedure would look like if I wanted the form to open to the last record?

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Auto-start Form at Last Record

    First define last record. Record order doesn't really mean anything in Access, so do you mean the most recently added record, the last on in a particular sort order, the last record in the natural order of the table, or what?
    Charlotte

  3. #3
    2 Star Lounger
    Join Date
    Apr 2001
    Location
    Des Moines, Iowa
    Posts
    180
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Auto-start Form at Last Record

    Ok... I've an AutoID field that would do the trick. I'd be looking for the largest number in that field. Is this what you're asking for?

  4. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Auto-start Form at Last Record

    You could use the DMax function to look up the largest value in that field in the table. Then, if you're using DAO, dim a recordset variable and set it equal to the form's recordclone. Do a findfirst on the recordsetclone using the field name = the result of the DMax as the criteria string. Set the form's bookmark equal to the recordsetclone's bookmark and then destroy the recordset object.
    Charlotte

  5. #5
    2 Star Lounger
    Join Date
    Apr 2001
    Location
    Des Moines, Iowa
    Posts
    180
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Auto-start Form at Last Record

    I can barely follow the logic of your last post. I know nothing of VBA... I think I recognize DMax as a domain aggrigate function, and is DIM a way to define a variable? I greatly appreciate your willingness to help, but I'm just not smart enough to take your instructions and turn them into working code. In my non-educated state I would need the actual code to cut and paste. Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •