Hi
Can anyone help me with this ?
Its about the VAR "VareVar". How do I put this var in my SQL string ?
Look at this part of my SQL string(MySql):
HAVING (((T_FejlRecords.VareNr)= VareVar
Here is the full code:
Dim VareVar As String
Dim oDB As Database
Dim oQuery As QueryDef
Dim MySql As String
Set oDB = CurrentDb
Set oQuery = oDB.QueryDefs("Q_3monthBack_Prod")
VareVar = 51606106
MySql = "SELECT DISTINCTROW Format$(T_FejlRecords.DatoOpr,'mmmm
yyyy') AS [DatoOpr By Month], T_FejlRecords.VareNr, Count(*) AS [Count
Of T_FejlRecords] " & _
"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 " & _
"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))"
oQuery.SQL = MySql
Set oQuery = Nothing
Set oDB = Nothing
best regards Ronald