Select query from VBA

  • Thread starter brownti via AccessMonster.com
  • Start date
B

brownti via AccessMonster.com

i have a report that is generated off of a union query (qryMaterialCombine).
That union query is based off of a select query (qryPreCombine).
qryPreCombine looks at a form to get a date range and only supplies those
records to the union query (i do this because i dont want to group by that
date value in the union query). Once qryMaterialCombine has the correct
records, it displays them on a report and then i have a form that does some
filtering of that report. What i would like to do is when i click my apply
button on the form (which applies the filtering) is to rerun the select query
in case the date range has changed. i cant figure out how to run that select
query in VBA though. Below is the SQL for qryPreCombine which i would like
to run prior to doing any filtering. Any thoughts?

"SELECT tblPriorities.BuilderDueDate, tblBuilderNames.Name, tblPriorities.
JobName, " & _
"tblPriorities.SalesPerson, tblMarkups.LaborRate, tblMarkups.LaborTotal,
tblMarkups.MillworkMU, " & _
"tblMarkups.MillworkTotal, tblMarkups.WoodDoorMU, tblMarkups.WoodDoorTotal,
tblMarkups.HardwareMU, " & _
"tblMarkups.HardwareTotal, tblMarkups.HollowMetalMU, tblMarkups.
HollowMetalTotal, tblMarkups.CabinetMU, " & _
"tblMarkups.CabinetTotal, tblMarkups.CountertopMU, tblMarkups.CountertopTotal
" & _
"FROM tblMarkups INNER JOIN (tblBuilderNames INNER JOIN tblPriorities ON
tblBuilderNames.BuilderID = " & _
"tblPriorities.BuilderID) ON tblMarkups.JobID = tblPriorities.JobID " & _
"WHERE (((tblPriorities.BuilderDueDate)>[Forms]![frmReportNavigator]!
[cboStartDate] And " & _
"(tblPriorities.BuilderDueDate)<[Forms]![frmReportNavigator]![cboEndDate]));"
 
B

brownti via AccessMonster.com

Upon further thought, i don't think this is the route i want to take. I will
take this thread to queries as i think it is a problem that can be solved
there.
i have a report that is generated off of a union query (qryMaterialCombine).
That union query is based off of a select query (qryPreCombine).
qryPreCombine looks at a form to get a date range and only supplies those
records to the union query (i do this because i dont want to group by that
date value in the union query). Once qryMaterialCombine has the correct
records, it displays them on a report and then i have a form that does some
filtering of that report. What i would like to do is when i click my apply
button on the form (which applies the filtering) is to rerun the select query
in case the date range has changed. i cant figure out how to run that select
query in VBA though. Below is the SQL for qryPreCombine which i would like
to run prior to doing any filtering. Any thoughts?

"SELECT tblPriorities.BuilderDueDate, tblBuilderNames.Name, tblPriorities.
JobName, " & _
"tblPriorities.SalesPerson, tblMarkups.LaborRate, tblMarkups.LaborTotal,
tblMarkups.MillworkMU, " & _
"tblMarkups.MillworkTotal, tblMarkups.WoodDoorMU, tblMarkups.WoodDoorTotal,
tblMarkups.HardwareMU, " & _
"tblMarkups.HardwareTotal, tblMarkups.HollowMetalMU, tblMarkups.
HollowMetalTotal, tblMarkups.CabinetMU, " & _
"tblMarkups.CabinetTotal, tblMarkups.CountertopMU, tblMarkups.CountertopTotal
" & _
"FROM tblMarkups INNER JOIN (tblBuilderNames INNER JOIN tblPriorities ON
tblBuilderNames.BuilderID = " & _
"tblPriorities.BuilderID) ON tblMarkups.JobID = tblPriorities.JobID " & _
"WHERE (((tblPriorities.BuilderDueDate)>[Forms]![frmReportNavigator]!
[cboStartDate] And " & _
"(tblPriorities.BuilderDueDate)<[Forms]![frmReportNavigator]![cboEndDate]));"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top