To modify a query in VBA code use the following as an example:
Code:
Dim db as DAO.Database
Set db = CurrentDB
db.QueryDefs("[i]yourqueryname[/i]").SQL = "Select A.Field1, A.Field2, A.Field3 as " & Me.Label1.caption & ", A.Field4 FROM [i]tablename[/i] as A ORDER BY A.Field1;"
db.close
This code will modify the actual SQL code of the query with VBA code to the caption value of the label on the form that is making the call to the sub. The query is an example an obviously you will want to adapt it to your query SQL code. Make sure to leave a space on either side of the label caption.
Post back if you have any questions.
Bob Scriver
[blue]Want the best answers? See FAQ181-2886[/blue]
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.