Open report based on Two combo Selections (Category & Report Name)

mba_110

Board Regular
Joined
Nov 28, 2012
Messages
80
Office Version
  1. 365
Platform
  1. Windows
Hi everyone,

I am doing a small exercise for opening report from my form based on report name as i have 100 reports so it need to be done very precisely however i have a table called tblRepots which has category, Reportname, and Reportlocation actually reportLocation is the real/saved name of report and Report name is the detailed name for users to open it from frmExtindividualRpts with btnPrintPreview.

Here is i have a code but unable to complete it, any help here will be much appreciated.


Code:
Private Sub BtnPrintPreview_Click()
On Error GoTo errhandlers:


'Check to see if data is entered into the Combo boxes or not.


If IsNull(Me.cboEmpId_RC) Or cboEmpId_RC = "" Then
    MsgBox "You must select Employee ID !", vbOKOnly, "Required Data"
If IsNull(Me.cboCatagory) Or cboCatagory = "" Then
    MsgBox "You must select Report Catagory !", vbOKOnly, "Required Data"
If IsNull(Me.cboReportName) Or cboReportName = "" Then
    MsgBox "You must select Report name !", vbOKOnly, "Required Data"
Else






exit_errhandlers:Exit Sub
errhandlers:
    MsgBox Err.Description, vbCritical
    Err.Clear
    End Sub


I need the else area code if all are correct then that specific report need to open, i dont know it can be done referencing the table field or any other method.

Thanks
 
Last edited:

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Code:
Private Sub btnPrintPreview_Click()
On Error GoTo errhandlers:

if not IsNull(cboEmpId_RC) then sWhere= "[field]='" & Me.cboEmpId_RC & "'"

docmd.OpenReport Me.cboReportName ,acViewPreview ,,sWhere

exit sub
errhandlers:
msgbox Err.description,,err
end sub
 
Last edited:
Upvote 0
Many Thks but the situation here is now i have to rename the reports to the combo box selection.

the field ReportLocation is stands for real report name which i cannot mention on combo box, otherwise users will get confused with short name of report.

that's why i have added the field in tblReports as [reportLocation] just not to confuse the users.

and also when cboEmpId_RC stay blank then it should ask to select it before proceeding the task.

"tblReports",[ReportLocation] is a real name saved in this field for reports.
cboReportName is a combo box with report Name for users who don't know the access coding.

I need to tell that cboReportName selection should open the report mentioned in tblreports,[ReportLocation] based on cboEmpId_RC which has actual name of report saved in DB, same should be applied for remaining reports command should follow the tblreports field reportlocation based on combo selection but open the only name saved in reportlocation field.


Sounds like complicated, sorry for bothering you again.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,221,710
Messages
6,161,445
Members
451,706
Latest member
SMB1982

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top