Friday, May 22, 2009

Create Select Query Using SQL in VBA

Add Microsoft DAO 3.6 object librery...from Tools > Referance
 
Sub Create_Query()
Dim strsql As String
Dim myquery As DAO.QueryDef
 
Set myquery = CurrentDb.CreateQueryDef("Mytable")
 
strsql = "Select * from [TableNme] where [Fieldname]=""Criteria"""
 
myquery.SQL = strsql
myquery.Close
 
DoCmd.OpenQuery "Mytable"
 
End Sub


Explore and discover exciting holidays and getaways with Yahoo! India Travel Click here!

No comments:

Post a Comment