Hello,
i have 4 checkboxes and have differnet queries that go along with it that i want to export to Excel. So the way i written the code is as follows,
So if chkbox1 is clicked then qry1 is run and exported
if chkbox2 is clicked then qry2 is run and exported
if chkbox1 and 2 are clicked then qryall (seprate qry then qry1 and qry2) is run and exported
For Each ctl In MyForm.Controls
Select Case ctl.ControlType
Case acCheckBox
If qry1.Value = True Then
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "qry1", fileIn, True, "Export"
ElseIf qry2.Value = True Then
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "qry2", fileIn, True, "Export"
ElseIf qry1.value = True and qry2.Value = True Then
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "qryall", fileIn, True, "Export"
End If
End Select
however what happens is if i choose both checkboxes then it only reports out the results from checkbox 1... can anyone help to see what i am doing wrong?
i have 4 checkboxes and have differnet queries that go along with it that i want to export to Excel. So the way i written the code is as follows,
So if chkbox1 is clicked then qry1 is run and exported
if chkbox2 is clicked then qry2 is run and exported
if chkbox1 and 2 are clicked then qryall (seprate qry then qry1 and qry2) is run and exported
For Each ctl In MyForm.Controls
Select Case ctl.ControlType
Case acCheckBox
If qry1.Value = True Then
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "qry1", fileIn, True, "Export"
ElseIf qry2.Value = True Then
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "qry2", fileIn, True, "Export"
ElseIf qry1.value = True and qry2.Value = True Then
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "qryall", fileIn, True, "Export"
End If
End Select
however what happens is if i choose both checkboxes then it only reports out the results from checkbox 1... can anyone help to see what i am doing wrong?