I’m setting up a database for a hedgehog hospital to record new arrivals.
Records have an RefID autonumber primary key, AdmissionDate, Refindex number if more than one arrive in a batch on the same day, and other details. The user wants a Reference field, which is created in the user form by linking AdmissionDate and the Refindex order of being entered into the database.
This is a section from the Hogdata table.
The user form has this
The result at present is that the form opens to RefID 81, or the first record for the latest date 04/12/2019. This is the first of 4 for this most recent batch of arrivals.
I want it to open to the most recent one, RefID 178. The Previous/Next buttons need to give the right sequence too.
Opening the form to the highest RefID would solve this but there’s always a possibility that hogs might need be added to an earlier arrival. Purely sorting on RefID would make a wrong sequence when navigating using Previous/Next.
Ideal would be to sort on the Reference field, which is a combination of a date and a number. How do I do this?
I tried making a numerical AdmissionDate and adding the RefID to it but this just moved the date forward.
Records have an RefID autonumber primary key, AdmissionDate, Refindex number if more than one arrive in a batch on the same day, and other details. The user wants a Reference field, which is created in the user form by linking AdmissionDate and the Refindex order of being entered into the database.
This is a section from the Hogdata table.
The user form has this
Code:
Private Sub Form_Open(Cancel As Integer)
DoCmd.GoToRecord , , acLast
End Sub
The result at present is that the form opens to RefID 81, or the first record for the latest date 04/12/2019. This is the first of 4 for this most recent batch of arrivals.
I want it to open to the most recent one, RefID 178. The Previous/Next buttons need to give the right sequence too.
Opening the form to the highest RefID would solve this but there’s always a possibility that hogs might need be added to an earlier arrival. Purely sorting on RefID would make a wrong sequence when navigating using Previous/Next.
Ideal would be to sort on the Reference field, which is a combination of a date and a number. How do I do this?
I tried making a numerical AdmissionDate and adding the RefID to it but this just moved the date forward.