opening query from listbox

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello. I have a situation in which the users want to open queries in
datasheet view two ways;

1) by double clicking the qry name in a listbox (lstQueriesAvailable)
2) by selecting the qry name from the list and then using a button

I am thinking about this too hard and not seeing what the coding would be
for either. I have opened a single query from a docmd.openquery line before
but this is perplexing.

If anyone has the info, help. Thanks in advance for any assistance.
*** John
 
John,

How you get the query names into the listbox you haven't said, but assuming
you've already done so...

'Declarations Section
Private varQueryName As Variant

Private Sub MyListBox_Click()
varQueryName = Me.MyListBox
End Sub

Private Sub MyListBox_DblClick()
Call cmdRunQuery_Click
End Sub

Private Sub cmdRunQuery_Click()
If Not IsNull(varQueryName) Then
DoCmd.OpenQuery varQueryName
End If
End Sub

Regards,
Graham R Seach
Microsoft Access MVP
Canberra, Australia
 
Back
Top