Macro to select first record in listbox

gem1204

Registered User.
Local time
Today, 12:53
Joined
Oct 22, 2004
Messages
54
I'm helping a friend who's taking a MS Access 2013 course.
she has an exercise that requires her to create a macro so that when a forms opens a list box is selected and the first item in the listbox is selected. I know how to do that in code

Code:
Private Sub Form_Load()
    Me.cmboQuery.SetFocus
    Me.cmboQuery = Me.cmboQuery.ItemData(0)
End Sub

I know how to set focus to the listbox but how do you select the first item in the listbox with a Macro?

She also has to create a macro for two command buttons. One button will open the query in datasheet view and the other to open the selected query in print preview. Again I know how to do this with VBA but how do you open a query based on the value of a list box using a macro?

It seems like someone is getting macros and vba confused but I'm looking at her book and it says Macros

Thanks
 

Users who are viewing this thread

Back
Top Bottom