Question : Need help with access report form

I have a large query with about 7 unioned selects. I have created a form with a dropdown list for the user to select a value. When I push a button I want to pass that value to the query and then display the results in a report.

Questions:

How do I modify the query to accept the parameter (I'm working in SQL mode because design view doesn't work with this union). Does this go in each where clause?

How do I code the button event to call the query with the parameter?

Thanks

Answer : Need help with access report form

Then just build a temporary table that holds ALL the names in a single field, along with an address:

Currentdb.Execute "Select Address, csz INTO YourTempTable FROM Select Distinct Address, csz FROM YourExistingTable"

Now add a SendTo field:

Currentdb.Execute "ALTER TABLE YourTempTable ADD COLUMN SendTo TEXT(255)"

Now build a recordset where you can loop through all names for a specific Address + csz, and concatenate the names:

Dim rst As DAO.Recordset
Dim rstNames as DAO.Recordset
Dim sNames as String

set rst = Currentdb.OpenRecordset("SELECT * FROM YourTempTable")

Do Until rst.EOF
  Set rstNames = Currentdb.Openrecordset("SELECT * FROM YourExistingTable WHERE [Address]='" & rst("Address") & "' AND csz='" & rst("csz") & "')"
  sNames = ""
  Do until rstNames.EOF
    sNames = sNames & vbCrLf & rstNames("First_Name") & " " & rstNames("Last_Name")
    rstNames.movenext
  Loop
  rst.Edit
  rst("SendTo") = sNames
  rst.Update
Loop
Random Solutions  
 
programming4us programming4us