Link to home
Start Free TrialLog in
Avatar of PeterBaileyUk
PeterBaileyUk

asked on

how to test parameter passing from excel-access

I have a number of subs one for each vehicle category per client (8 clients in all)

The results i am getting do not correspond to the query result.

If i run the query in access i enter the same parameters and the query gives the correct result.

If i run the sub for that category and pass the same parameters I get a different result.

How do I test this?

The only difference between each sub is the value of parameters and the cell destination.

Sub GetKeeTotalNewCodesMatchedCarsSMMT2012()
    Set qdf = db.QueryDefs("Query2")
    
 
    Set RstCurrentYearMonth = db.OpenRecordset("SELECT Max(CWSMMTBuilds.BuildYearMonth) AS MaxOfBuildYearMonth FROM CWSMMTBuilds;", dbReadOnly)
    
    'get current data month
    With RstCurrentYearMonth
    .MoveLast
    CurrentDataMonth = .Fields("MaxofBuildYearMonth").Value
    
    End With
      
    datMonth = #1/1/2012#
   
    
    Do While datMonth <= CurrentDataMonth
     
        qdf.Parameters("[Yes=CW Codes/No=SMMT Codes]").Value = False
        qdf.Parameters("[Enter Cars, Bikes, Lcv, Others]").Value = "Cars"
          qdf.Parameters("[Yes=Matched Abi/No=No Match Abi]").Value = Null
        qdf.Parameters("[Yes=Matched Cap/No=No Match Cap]").Value = Null
        qdf.Parameters("[Yes=Matched Glass/No=No Match Glass]").Value = Null
        qdf.Parameters("[Yes=Matched Adl/No=No Match Adl]").Value = False
        qdf.Parameters("[Yes=Matched Insecom/No=No Match Insecom]").Value = Null
        qdf.Parameters("[Yes=Matched Techdoc/No=No Match Techdoc]").Value = Null
        qdf.Parameters("[Yes=Matched Halfords/No=No Match Halfords]").Value = Null
        qdf.Parameters("[Yes=Matched Kee/No=No Match Kee]").Value = True
        qdf.Parameters("[Yes=Matched Vivid/No=No Match Vivid]").Value = Null
         qdf.Parameters("BYM") = DateSerial(Format(datMonth, "yyyy"), Format(datMonth, "mm"), 1)
        
        


          With wks.Cells(84, Format(datMonth, "mm") + 1)

            .Select
            .Value = "...."
            DoEvents
            .Value = qdf.OpenRecordset!Nb
            DoEvents
        End With
        
        datMonth = DateAdd("m", 1, datMonth)
       
    Loop

Set RstCurrentYearMonth = Nothing
'db.Close
'Set db = Nothing
Set qdf.Parameters = Nothing

End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of elevationkevin
elevationkevin
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of PeterBaileyUk
PeterBaileyUk

ASKER

thank you for such detailed response