append filtered datasheet to Temp table

KoubuG

New member
Local time
Today, 03:40
Joined
Sep 5, 2019
Messages
1
Hello,

I have a datasheet form called "contact list" where the user will filter through and I want to be able to append those filtered fields values displayed into a temp table that will be used to send mass email through a command button. Any help is much appreciated.

Thank you !
 
Hi. Welcome to AWF! As the user filters the form, this information is stored in the Filter property of the form. You should be able to use this information for your email button.
 
This is a fairly common topic. How should user filter and select records? If filter is based on data (such as "all records with zip code 99999*"), there is no need for a temp table. If users need to make arbitrary selection of unrelated records, that is difficult in a multi-user database.

Is this database split design?
 
create another form and put the datasheet form as subform.
create a button on the main form to append filtered records.
on the click of that button add code that will save it to temp table:
Code:
private sub button_click()
dim db as dao.database
dim qd as dao.querydef
if me.datasheet.form.filteron then
    set db = currentdb
    with me.datasheetName.Form.recordsetclone
         while not .eof
             set qd = _
             db.createquerydefs("", "insert into temp_table (field1, fiel2, field3, …) " & _
                              "select  p0, p1, p2, …")
             qd.parameters(0) = !field1
             qd.parameters(1) = !field2
             qd.parameters(2) = !field3
                 ...     
                 ...
             qd.execute
             .movenext
         wend
    end with
end if
end sub
 

Users who are viewing this thread

Back
Top Bottom