Select criteria to transfer to Excel Spreadsheet

Nyneave

New member
Local time
Today, 09:58
Joined
Jul 24, 2012
Messages
4
I am trying to build a form with checkboxes to select which records will pull to an external spreadsheet. There needs to be a separate spreadsheet for each item selected. For example, checking which hospitals I want to include (ie...AMC, BMC, BCS, etc...). The user would check which hospital records to pull and based on that selection (upon clicking a button); records with that hospital identified will output to excel. All AMC records would be in one worksheet, all BMC on another, BCS on another, etc...
 
This is totally possible to do, As I am not sure what your table structure is I am wring in general, you have to adapt it to your way of doing it.

STEP 1: All you have to do is create the queries by using the Query wizard maybe the code being
Code:
SELECT * FROM [B][I]tblName[/I][/B] WHERE [B][I]fieldName[/I][/B]='AMC'
and save them as say QryAMC, QryBMC, QryBCS etc.
STEP 2: Now, as you have said create the Form with the check boxes and on click of the button check which boxes have been clicked. something along the line of
Code:
Private Sub createRptBtn_OnClick()
        If AMC_ChkBox=-1 Then DoCmd.TransferSpreadSheet acExport, _
                                         acSpreadsheetTypeExcel9, QryAMC
        If BMC_ChkBox=-1 Then DoCmd.TransferSpreadSheet acExport, _
                                         acSpreadsheetTypeExcel9, QryBMC
        [COLOR="SeaGreen"]' So on and so forth until you have them all. [/COLOR]
End Sub
Hope this helps, post back if you find it hard.
 

Users who are viewing this thread

Back
Top Bottom