Kat,
One issue is naming something "name" which reserved word since practically everything has a name property. Change the control name to txtName and try:
If Not IsNull(Me.txtName) Then
strWhere = strWhere & " AND [Name] = """ & Me.txtName & """ "
End If
Use the combo box control name, not the "caption" property of the label.
Duane Hookom, MVP
MS Access
To: MS_Access_Professionals@yahoogroups.com
From: no_reply@yahoogroups.com
Date: Wed, 24 Feb 2016 08:37:56 -0800
Subject: RE: [MS_AccessPros] Need help with a Report
Hi Duane!
Thanks so much for your reply. Please know that I am a novice when it comes to coding, so your help is greatly appreciated!! I put in the code you gave me for my "View Report" button...here is the code for the button:
Private Sub Command93_Click()
Dim strReport As String
Select Case Me.RptOpt
Case Is = 1
strReport = "R_TrainingHistConfig"
DoCmd.RunMacro "TrainingHistConfig"
Case Is = 2
strReport = "R_TrnTrxnClassRoster"
DoCmd.RunMacro "TrnClassRpt"
Case Is = 3
strReport = "R_TrainingClassDetail4DateRange"
DoCmd.RunMacro "TrainingbyDateRanges"
Case Is = 4
strReport = "Report all Active Emp"
Case Is = 5
strReport = "R_Active Emp By Dept"
Case Is = 6
strReport = "R_TrnTrxnScheduleDateRange"
DoCmd.RunMacro "TrainingScheduleDateRange"
Case Is = 7
strReport = "R_TrnTrxnClassRosterDateRange"
DoCmd.RunMacro "TrainingClassRosterDateRange"
Case Is = 8
Dim strWhere As String
strWhere = "1=1 "
If Not IsNull(Me.Name) Then
strWhere = strWhere & " AND [Name] = """ & Me.Name & """ "
End If
If Not IsNull(Me.CDesc) Then
strWhere = strWhere & " AND [CDesc] = """ & Me.CDesc & """ "
End If
' add more controls and where conditions
strReport = "R_TrnHist4SpecificEmp"
DoCmd.OpenReport "R_TrnHist4SpecificEmp", acViewPreview, , strWhere
End Select
DoCmd.Close acForm, "f_ConfigRpts"
DoCmd.OpenReport strReport, acViewPreview
End Sub
When I select an employee name and a class description, and select the training history for specific employee option button, and click on the view report button, a "Enter Parameter Value" for the CDesc comes up. I've check the labels for my combo box on the form, and the text box on the report, and they are corrent. I'm not sure what I'm doing wrong.
Thanks so much for your help!
Kat
One issue is naming something "name" which reserved word since practically everything has a name property. Change the control name to txtName and try:
If Not IsNull(Me.txtName) Then
strWhere = strWhere & " AND [Name] = """ & Me.txtName & """ "
End If
Use the combo box control name, not the "caption" property of the label.
Duane Hookom, MVP
MS Access
To: MS_Access_Professionals@yahoogroups.com
From: no_reply@yahoogroups.com
Date: Wed, 24 Feb 2016 08:37:56 -0800
Subject: RE: [MS_AccessPros] Need help with a Report
Hi Duane!
Thanks so much for your reply. Please know that I am a novice when it comes to coding, so your help is greatly appreciated!! I put in the code you gave me for my "View Report" button...here is the code for the button:
Private Sub Command93_Click()
Dim strReport As String
Select Case Me.RptOpt
Case Is = 1
strReport = "R_TrainingHistConfig"
DoCmd.RunMacro "TrainingHistConfig"
Case Is = 2
strReport = "R_TrnTrxnClassRoster"
DoCmd.RunMacro "TrnClassRpt"
Case Is = 3
strReport = "R_TrainingClassDetail4DateRange"
DoCmd.RunMacro "TrainingbyDateRanges"
Case Is = 4
strReport = "Report all Active Emp"
Case Is = 5
strReport = "R_Active Emp By Dept"
Case Is = 6
strReport = "R_TrnTrxnScheduleDateRange"
DoCmd.RunMacro "TrainingScheduleDateRange"
Case Is = 7
strReport = "R_TrnTrxnClassRosterDateRange"
DoCmd.RunMacro "TrainingClassRosterDateRange"
Case Is = 8
Dim strWhere As String
strWhere = "1=1 "
If Not IsNull(Me.Name) Then
strWhere = strWhere & " AND [Name] = """ & Me.Name & """ "
End If
If Not IsNull(Me.CDesc) Then
strWhere = strWhere & " AND [CDesc] = """ & Me.CDesc & """ "
End If
' add more controls and where conditions
strReport = "R_TrnHist4SpecificEmp"
DoCmd.OpenReport "R_TrnHist4SpecificEmp", acViewPreview, , strWhere
End Select
DoCmd.Close acForm, "f_ConfigRpts"
DoCmd.OpenReport strReport, acViewPreview
End Sub
When I select an employee name and a class description, and select the training history for specific employee option button, and click on the view report button, a "Enter Parameter Value" for the CDesc comes up. I've check the labels for my combo box on the form, and the text box on the report, and they are corrent. I'm not sure what I'm doing wrong.
Thanks so much for your help!
Kat
__._,_.___
Posted by: Duane Hookom <duanehookom@hotmail.com>
Reply via web post | • | Reply to sender | • | Reply to group | • | Start a New Topic | • | Messages in this topic (4) |
.
__,_._,___
Tidak ada komentar:
Posting Komentar