J
Jops
I do not know how to code and I've gotten this visual basic code off the
internet. It is assigned to a click on event for the generate report button
in my parameters form. This code I found allows fro multiple parameters,
date ranges and also allows for null values to be entered. I have been
trying to modify it so I can add a multi-valued field as the first parameter.
The part that the access has an error occur on is the
[T_CourseDev.Program_Code.Value]. When I run it and leave that parameter
blank no problem, if I pick something for that parameter I get this error:
Run-time error '3125' "is not a valid name. Make sure that it does not
include invalid characters or punctuation and that it is not too long.
Private Sub cmdGenerateReport_Click()
Dim stDocName As String
Dim stWhere As String
Dim stDates As String
Dim blnTrim As Boolean
If Not IsNull(Me.cbo_Programfilter) Then
stWhere = " [T_CourseDev.Program_Code.Value] =" &
Me.cbo_Programfilter & " And "
blnTrim = True
End If
If Not IsNull(Me.cbo_DevstatusFilter) Then
stWhere = stWhere & "[DevStatus]=" & Me.cbo_DevstatusFilter & "
And "
blnTrim = True
End If
If IsNull(Me.CourseStart_start) And Me.CourseStart_start = "" Then
If Not IsNull(Me.CourseStart_End) And Me.CourseStart_End <> ""
Then
stWhere = stWhere & "[Course_Start] <=" &
Me.CourseStart_End & "#"
blnTrim = False
End If
Else
If IsNull(Me.CourseStart_End) And Me.CourseStart_End = "" Then
If Not IsNull(Me.CourseStart_start) And Me.CourseStart_start
<> "" Then
stWhere = stWhere & "[Course_Start]>=" &
Me.CourseStart_start
blnTrim = False
End If
Else
If (Not IsNull(Me.CourseStart_start) And
Me.CourseStart_start <> "") And (Not IsNull(Me.CourseStart_End) Or
Me.CourseStart_End <> "") Then
stWhere = stWhere & "[Course_Start] Between #" &
Me.CourseStart_start & "# And #" & Me.CourseStart_End & "#"
blnTrim = False
End If
End If
End If
If blnTrim Then
stWhere = Left(stWhere, Len(stWhere) - 5)
End If
stDocName = "R_CourseDev"
DoCmd.OpenReport stDocName, acPreview, , stWhere
DoCmd.Close acForm, "pF_ProgramList"
Exit_cmdGenerateReport_Click:
Exit Sub
Err_cmdGenerateReport_Click:
MsgBox Err.Description
Resume Exit_cmdGenerateReport_Click
internet. It is assigned to a click on event for the generate report button
in my parameters form. This code I found allows fro multiple parameters,
date ranges and also allows for null values to be entered. I have been
trying to modify it so I can add a multi-valued field as the first parameter.
The part that the access has an error occur on is the
[T_CourseDev.Program_Code.Value]. When I run it and leave that parameter
blank no problem, if I pick something for that parameter I get this error:
Run-time error '3125' "is not a valid name. Make sure that it does not
include invalid characters or punctuation and that it is not too long.
Private Sub cmdGenerateReport_Click()
Dim stDocName As String
Dim stWhere As String
Dim stDates As String
Dim blnTrim As Boolean
If Not IsNull(Me.cbo_Programfilter) Then
stWhere = " [T_CourseDev.Program_Code.Value] =" &
Me.cbo_Programfilter & " And "
blnTrim = True
End If
If Not IsNull(Me.cbo_DevstatusFilter) Then
stWhere = stWhere & "[DevStatus]=" & Me.cbo_DevstatusFilter & "
And "
blnTrim = True
End If
If IsNull(Me.CourseStart_start) And Me.CourseStart_start = "" Then
If Not IsNull(Me.CourseStart_End) And Me.CourseStart_End <> ""
Then
stWhere = stWhere & "[Course_Start] <=" &
Me.CourseStart_End & "#"
blnTrim = False
End If
Else
If IsNull(Me.CourseStart_End) And Me.CourseStart_End = "" Then
If Not IsNull(Me.CourseStart_start) And Me.CourseStart_start
<> "" Then
stWhere = stWhere & "[Course_Start]>=" &
Me.CourseStart_start
blnTrim = False
End If
Else
If (Not IsNull(Me.CourseStart_start) And
Me.CourseStart_start <> "") And (Not IsNull(Me.CourseStart_End) Or
Me.CourseStart_End <> "") Then
stWhere = stWhere & "[Course_Start] Between #" &
Me.CourseStart_start & "# And #" & Me.CourseStart_End & "#"
blnTrim = False
End If
End If
End If
If blnTrim Then
stWhere = Left(stWhere, Len(stWhere) - 5)
End If
stDocName = "R_CourseDev"
DoCmd.OpenReport stDocName, acPreview, , stWhere
DoCmd.Close acForm, "pF_ProgramList"
Exit_cmdGenerateReport_Click:
Exit Sub
Err_cmdGenerateReport_Click:
MsgBox Err.Description
Resume Exit_cmdGenerateReport_Click