• Auto-start Form at Last Record

    Author
    Topic
    #355594

    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?

    Viewing 0 reply threads
    Author
    Replies
    • #524755

      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?

      • #524758

        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?

        • #524808

          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.

          • #524841

            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.

    Viewing 0 reply threads
    Reply To: Auto-start Form at Last Record

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: