[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

how to loop through parameters in qdf object

Posted on 2012-08-11
13
Medium Priority
?
701 Views
Last Modified: 2012-08-12
I want to debug a qdf object and see what actual parameters were passed.

not sure how:

something like

with qdf.parameters
debug.print qdf parameter

not sure about the looping.

i am in excel vba
0
Comment
Question by:PeterBaileyUk
  • 7
  • 4
  • 2
13 Comments
 
LVL 5

Expert Comment

by:elevationkevin
ID: 38284856
I had a similiar problem and this website helped.

http://msdn.microsoft.com/en-us/library/office/bb177500(v=office.12).aspx
0
 

Author Comment

by:PeterBaileyUk
ID: 38284870
I did this:

Dim db As DAO.Database
Dim qdf As DAO.QueryDef  

   

       For Each qdf In QueryDef
            Debug.Print qdf
       
        Next qdf

that didnt work.
0
 

Author Comment

by:PeterBaileyUk
ID: 38284877
now getting
  For Each qdf In db.QueryDefs
            Debug.Print qdf.Properties

        Next qdf

not sure how to return the values that were passed
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 5

Expert Comment

by:elevationkevin
ID: 38284887
Your code looks right and you say that the msgbox only show the querys that you're interested in? If so then that is confusing to me.


does the msgbox says
msgbox (qrydef)

when it should be

msgbox (qdf.SQL)
or
msgbox (qdf.Name)

Code:
Function ReplaceFieldNames()
   Dim db As DAO.Database
   Dim qdf As DAO.QueryDef
   
   Set db = CurrentDb
   
   For Each qdf In db.QueryDefs
      If Left(qdf.Name,3) = "LBR" Then
         debug.print (qdf.SQL)
         qdf.SQL = Replace(qdf.SQL, "LBR", "RAC")
         debug.print (qdf.SQL)
      End If
   Next qdf
End Function

Maybe try stepping through that and see what happens with that?
Tts really no different from what you've already done but I guess I'm just sending my thoughts to ya as they come through my head ;)
0
 

Author Comment

by:PeterBaileyUk
ID: 38284903
What I wanted to see was first what parameters the qdf object in that instance holds.

I don want to assume its what it was set as:

   qdf.Parameters("[Yes=CW Codes/No=SMMT Codes]").Value = True
        qdf.Parameters("[Enter Cars, Bikes, Lcv, Others]").Value = "Others"
          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 = True
        qdf.Parameters("[Yes=Matched Adl/No=No Match Adl]").Value = Null
        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 = Null
        qdf.Parameters("[Yes=Matched Vivid/No=No Match Vivid]").Value = Null
         qdf.Parameters("BYM") = DateSerial(Format(datMonth, "yyyy"), Format(datMonth, "mm"), 1)

Open in new window

0
 

Author Comment

by:PeterBaileyUk
ID: 38284904
I will step through as suggested and see what it gives.
0
 
LVL 52

Accepted Solution

by:
Gustav Brock earned 2000 total points
ID: 38284911
It's easier than you think:

Dim prm As Parameter

For each prm In qdf.Parameters
  Debug.Print prm.Name, prm.Value
Next

/gustav
0
 

Author Comment

by:PeterBaileyUk
ID: 38284914
are LBR and rac the field names i change? ie add a field for each parameter?
0
 
LVL 5

Expert Comment

by:elevationkevin
ID: 38284920
Good one cactus! I think that will be helpful!
0
 

Author Comment

by:PeterBaileyUk
ID: 38284943
spoke too soon it says type mismatch
on the for
it must be close!
0
 

Author Comment

by:PeterBaileyUk
ID: 38284949
got it dao.parameter!
0
 
LVL 5

Expert Comment

by:elevationkevin
ID: 38284952
Awesome!
0
 
LVL 52

Expert Comment

by:Gustav Brock
ID: 38284957
You are welcome!

/gustav
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
In a use case, a user needs to close an opened report by simply pressing the Escape (Esc) key. This can be done by adding macro code in Report_KeyPress or Report_KeyDown event.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question