Code Examples

Create A New Query

acCmdAdvancedFilterSort, acCmdSaveAsQuery

This is an adaptation of some code I found on the newsgroup posted by Alan Taw. He was trying to create a new query based on a table but it gave me the outline for the following. It does however use Sendkeys and has no error checking.

'***************** Code Start *******************
SendKeys information

Sub CreateQuery(strTableName As String, strQueryName As String)

  DoCmd.OpenTable strTableName
  DoCmd.RunCommand acCmdAdvancedFilterSort
  SendKeys "~", False
  DoCmd.RunCommand acCmdSaveAsQuery
  DoCmd.Close acTable, strTableName
  DoCmd.Rename strQueryName, acQuery, "query1"

End Sub

'****************** Code End ********************

© 1998 - 2011 Terry Wickenden TKW Design Site developed, maintained and hosted by TKW Design. This site is best viewed at 1024 x 768. Optimised for Firefox.