Go To Record in List Box

Sharon Hague

Registered User.
Local time
Today, 21:03
Joined
Jul 10, 2003
Messages
138
Hi All

I have created a form from a table called Record Selection which is basically a list box showing various record information. I have set the primary key on record entry. Upon selection of a record in the list box it opens that record in full from another form based on a query.

When the Record Selection form is opened it sorts the list in record entry order. There are hundreds of records in here & rather than scrolling down or to the end of the list I want to be able to "Go To" the last entry in the list box automatically once this form is opened. I have tried the "Go To Record" in Macros but can't seem to get anywhere with it.

Any idea's?
 
Place this in the OnOpen event of the form
Code:
Private Sub Form_Open(Cancel As Integer)

Me.YourControlName.SetFocus
DoCmd.GoToRecord , , acLast

End Sub

Change 'YourControlName' to the name of the control you want the focus set to.
Hope this helps

IMO
 
IMO

Thanks for replying so soon, however unfortunately nothing happens.

My control name is List8 which is my name of my list box in my form which shows all records.

Therefore my control box now reads: -

Private Sub Form_Open(Cancel As Integer)
Me.List8.SetFocus
DoCmd.GoToRecord , , acLast

End Sub

My OnOpen properties to the form now displays [Event Proceedure] which when you go to build displays the above.

When I open the form nothing happens and waits for me to select a record like before.

Have I missed something?
 
Ahhh, I thought you wanted it to go to the last record on the form it opens. So you want to go to the last record in the ListBox. Have you got an Autonumber ID for each record in the table? If so, in design mode, right click the listbox and select properties. In the RowSource Click on the button next to the drop down. In the query select 'Sort' under the autonumber ID and change it to Descending. This will now order the ListBox with the last entry first in the list.

Hope this helps

IMO
 
Last edited:
Yes, the record Entry field which is the primary key is Autonumber.

Does that matter?
 
Ive just edited my post, see if that works for you

IMO
 
Thanks

It's worked a treat.

The amount of times I have used the control source, I have never noticed the build button towards the left.

Cheers.
 
Glad it worked for you

IMO
 

Users who are viewing this thread

Back
Top Bottom