Ok and thank you.
I have tried what Smartin did say and it works fine, but now I want to
get i dynamic.
I got this SQL statement:
1)"SELECT DISTINCTROW Format$(T_FejlRecords.DatoOpr,'mmmm yyyy')" & _
2)"AS [DatoOpr By Month], T_FejlRecords.VareNr, Count(*)" & _
3)"AS [Count Of T_FejlRecords] " & _
4)"FROM T_FejlRecords GROUP BY Format$(T_FejlRecords.DatoOpr,'mmmm
yyyy'), T_FejlRecords.VareNr,
Year(T_FejlRecords.DatoOpr)*12+DatePart('m',T_Fejl Records.DatoOpr)-1,
T_FejlRecords.Intern " & _
5)"HAVING (((T_FejlRecords.VareNr)=VareVar) AND
T_FejlRecords.Intern)=Yes) AND
((Year([T_FejlRecords].[DatoOpr])*12+DatePart('m',[T_FejlRecords].[DatoOpr])-1)>=Year(Date())*12+DatePart('m',Date())-4))"
If you look at 5) saying: HAVING (((T_FejlRecords.VareNr)=VareVar)
VareVar is a VAR. How do I "tell" the SQL statement that it is a VAR ?
It need some signs around, but witch one.
best regards
Ronald
Danny J. Lesandrini wrote:
Why not make the query parameter dynamic?
Private m_varQueryParam As Variant
Public Function SetQueryParam(ByVal sValue as Variant)
m_varQueryParam = sValue
End Function
Public Function GetQueryParam() As Variant
GetQueryParam = m_varQueryParam
End Function
Query:
SELECT * FROM tblYourTable WHERE [FilterField] = GetQueryParam()
The VBA Code to lajunch the query will look like this.
SetQueryParam "your value here"
DoCmd.OpenQuery "qryYourQueryHere"
--
Danny J. Lesandrini
dl*********@hotmail.com
http://amazecreations.com/datafast/
<bj**@vestas.com> wrote ... Hi
I need some help to my VBA code.
I want to open a query in Edit mode
Change a parameter and then save the qyery and close it.
A)I now how to do open the query in editmode
docmd.openquery ect ect.
B)I dont now how to change the parameter
C)but I now how to save the qyery and close it.
Can anyone help me to do the B) part ?
best regards
Ronald