Start A New Query
acCmdNewObjectQuery
This example opens the Query By Example grid and automatically inserts the table passed to it.
'***************** Code Start *******************

'Code by Terry Wickenden
Sub CreateQuery(strTable As String)
'Brings up the QBE grid with the table in it.
DoCmd.Echo False
DoCmd.SelectObject acTable, strTable, True
SendKeys "{enter}", False
DoCmd.RunCommand acCmdNewObjectQuery
DoCmd.Echo True
End Sub
'****************** Code End ********************