Hello everybody.
I made next function that open a report with a condition that is made from a combo box in a form what is attached with a checkbox. If the checkbox is valid then for the criteria is attached a additional condition.
The problem is the next: if there is more that one condition then its apear an message box that contains the value of condition. How can I change the function without having troubles with messageboxes ?
Private Sub Command116_Click()
On Error GoTo Err_Command116_Click
Dim stLinkCriteria1 As String
Dim Msg As String
stLinkCriteria1 = "[Fin_Program_ID]=" & Me![Fin_Program_ID]
If (Me![c2]) Then
stLinkCriteria1 = stLinkCriteria1 & " and [Project_Domain]=[" & [Project_Domain].Value & "]"
End If
If (Me![c3]) Then
stLinkCriteria1 = stLinkCriteria1 & " and [Project_Category]=[" & Me!Project_Category.Value & "]"
End If
If (Me![c4]) Then
stLinkCriteria1 = stLinkCriteria1 & " and [Project State]=[" & Me![Project State].Section & "]"
End If
DoCmd.OpenReport "Projects_full", acPreview, , stLinkCriteria1
Exit_Command116_Click:
Exit Sub
Err_Command116_Click:
MsgBox Err.description
Resume Exit_Command116_Click
End Sub
Another question for the same report: can I change the visibility of some fields in the report from VBA in the same function ???
I made next function that open a report with a condition that is made from a combo box in a form what is attached with a checkbox. If the checkbox is valid then for the criteria is attached a additional condition.
The problem is the next: if there is more that one condition then its apear an message box that contains the value of condition. How can I change the function without having troubles with messageboxes ?
Private Sub Command116_Click()
On Error GoTo Err_Command116_Click
Dim stLinkCriteria1 As String
Dim Msg As String
stLinkCriteria1 = "[Fin_Program_ID]=" & Me![Fin_Program_ID]
If (Me![c2]) Then
stLinkCriteria1 = stLinkCriteria1 & " and [Project_Domain]=[" & [Project_Domain].Value & "]"
End If
If (Me![c3]) Then
stLinkCriteria1 = stLinkCriteria1 & " and [Project_Category]=[" & Me!Project_Category.Value & "]"
End If
If (Me![c4]) Then
stLinkCriteria1 = stLinkCriteria1 & " and [Project State]=[" & Me![Project State].Section & "]"
End If
DoCmd.OpenReport "Projects_full", acPreview, , stLinkCriteria1
Exit_Command116_Click:
Exit Sub
Err_Command116_Click:
MsgBox Err.description
Resume Exit_Command116_Click
End Sub
Another question for the same report: can I change the visibility of some fields in the report from VBA in the same function ???
Last edited: