AboutScottgem Expertise I can answer some questions on a wide variety of business applications, including MS Office, Lotus Smartsuite, Visio, Notes and many others.
Experience I have over 16 years of experience as an IT professional, supporting a wide variety of business applications.
Question Hi Scott, thank you for helping with syntax, the code works up to the point of queryDef creation.
attyName = rs.Fields("Name")
MsgBox (attyName)
Set qd = db.CreateQueryDef("Dynamic_Query", "SELECT [Unit/Practice Area], [Account Name], " & _
"[Total Budgeted for 2009]," & _
"FROM IndividualBudget WHERE [Name] ='" & attyName & _
" ORDER BY [Name];")
DoCmd.OpenQuery "Dynamic_Query"
Answer Ahh I think I see the problem, Try changing this line to:
"' ORDER BY [Name];")
Since AttyName is a text string, you need to enclose it in quites and you are missing the right quote.
By the way, you really should change the NAME field to something like AttyName. in fact what you really should be doing is have an Attorney table with all the details about each attorney. Then use an Autonumber as a primary key and then use that value as a Foreign Key. You shouldn't be repeating the attorney's name so many times.
Hope this helps,
Scott<>
Microsoft Access MVP 2007
Author: Microsoft Office Access 2007 VBA
Irina,
Thanks for your rating and comments, but I wanted to return the favor. It has been a pleasure helping you. Too many times people ask a question and when I answer giving them what they need to work out a solution, they come back to me asking for clarification instead of using what I gave them to try and work it out. Too often people want too much hand holding. But you took what I gave you (which admittedly was pretty bare bones) and ran with it and made great strides in determing a solution, that just needed a few tweaks from an experienced eye to get to work. And I'm betting you learned a lot more in the process, then if I had just giving you the code.
Please feel free to call on me for any further help you need.