I have created a form in MS Access 2011 in which there are a tab control on top named TabCtl18 in which 3 tabs are page1, page2, page3. Under the page1 tab there are another 3 other tabs page11, page22, page33, under three tabs there are 3 reports respectively
Now I want that when a user clicks on pdf icon it check which tab has clicked and print that report.
My Code :
Private Sub cmdPrintReportPDF_Click()
If TabCtl18.TabIndex = 0 Then
If tab_graph.TabIndex = 0 Then
DoCmd.OpenReport "Graph_report", acViewNormal
DoCmd.OutputTo acOutputReport, "Graph_report"
DoCmd.Close acReport, "Graph_report"
End If
Else
If tab_graph.TabIndex = 2 Then
DoCmd.OpenReport "Graph_Report_FieldShifts", acViewNormal
DoCmd.OutputTo acOutputReport, "Graph_Report_FieldShifts"
DoCmd.Close acReport, "Graph_Report_FieldShifts"
End If
End If
End Sub
Based on issue highlighted by @David, here is the way to check name of the TabPage
selected.
if tabControl1.Pages(tabControl1.Value).Caption = "TabPageName" then
'Do Something
end if
Moreover, You can use this code in Tab
Control Click
Event to check which Page is active.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With