how can i edit query from VB code

D

dBoki

I need to edit sql code of exsisting query, from vba. Does anybody have some
expirience with that? Thanks
 
K

Klatuu

Here is an example of what you need.

'Get the Query to change
Set qdf = dbs.QueryDefs(strQryName)
strQry = qdf.SQL
'Strip out SumOf and replace with empty string
strQry = Replace(strQry, "SumOf", "")
'Add SumOf to field name to align with Table field name
strQry = Replace(strQry, strFind, strReplace)
'Fix the field name the previous replace changed
strQry = Replace(strQry, "zSumOf", "z")
qdf.SQL = strQry
qdf.Close
 
Top