I have a form named "frmCustomerRequests" which contains a sub form: "subfrmRequests" (linked via Customer_ID). On "frmMain" I have 2 command buttons 1. "Display All Requests" & 2. "Display Open Requests.
The coding for "Display All Requests" is as follows:
"
Private Sub cmdDisplayAllRequsets_Click()
On Error GoTo Err_cmdDisplayAllRequsets_Click
'exit this sub if customer name is cleared
If cboSearch.Value = "" Then
Msg = "Please enter the customer's name."
a = MsgBox(Msg, , "Blank Entry")
Exit Sub
End If
Me.Visible = False
Dim subfrmRequests As New Form_subfrmRequests
subfrmRequests.RecordSource = "tblRequests"
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmCustomerRequest"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Me.cboSearch = ""
Exit_cmdDisplayAllRequsets_Click:
Exit Sub
Err_cmdDisplayAllRequsets_Click:
MsgBox Err.Description
Resume Exit_cmdDisplayAllRequsets_Click
End Sub
"
The coding for "Display Open Requests" is as follows:
"
Private Sub cmdDisplayOpenRequests_Click()
On Error GoTo Err_cmdDisplayOpenRequsets_Click
'exit this sub if customer name is cleared
If cboSearch.Value = "" Then
Msg = "Please enter the customer's name."
a = MsgBox(Msg, , "Blank Entry")
Exit Sub
End If
Me.Visible = False
Dim subfrmRequests As New Form_subfrmRequests
subfrmRequests.RecordSource = "qryOpenRequests"
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmCustomerRequest"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Me.cboSearch = ""
Exit_cmdDisplayOpenRequsets_Click:
Exit Sub
Err_cmdDisplayOpenRequsets_Click:
MsgBox Err.Description
Resume Exit_cmdDisplayOpenRequsets_Click
End Sub
"
When user clicks on "Display Open Requests" I want "subfrmRequests" to display only the "open" requests, so I have created "qryOpenRequests" where the criteria for the "Requests_Status" is ="open". And in the coding I have tried to set the recordsource for "subfrmRequests" to "qryOpenRequests".
However this is not working. When I click on "Display Open Requests" it is still displaying requests with a "closed" status.
Is there something wrong with the command button coding for setting the sub form's record source (as in the above code)?
The coding for "Display All Requests" is as follows:
"
Private Sub cmdDisplayAllRequsets_Click()
On Error GoTo Err_cmdDisplayAllRequsets_Click
'exit this sub if customer name is cleared
If cboSearch.Value = "" Then
Msg = "Please enter the customer's name."
a = MsgBox(Msg, , "Blank Entry")
Exit Sub
End If
Me.Visible = False
Dim subfrmRequests As New Form_subfrmRequests
subfrmRequests.RecordSource = "tblRequests"
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmCustomerRequest"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Me.cboSearch = ""
Exit_cmdDisplayAllRequsets_Click:
Exit Sub
Err_cmdDisplayAllRequsets_Click:
MsgBox Err.Description
Resume Exit_cmdDisplayAllRequsets_Click
End Sub
"
The coding for "Display Open Requests" is as follows:
"
Private Sub cmdDisplayOpenRequests_Click()
On Error GoTo Err_cmdDisplayOpenRequsets_Click
'exit this sub if customer name is cleared
If cboSearch.Value = "" Then
Msg = "Please enter the customer's name."
a = MsgBox(Msg, , "Blank Entry")
Exit Sub
End If
Me.Visible = False
Dim subfrmRequests As New Form_subfrmRequests
subfrmRequests.RecordSource = "qryOpenRequests"
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmCustomerRequest"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Me.cboSearch = ""
Exit_cmdDisplayOpenRequsets_Click:
Exit Sub
Err_cmdDisplayOpenRequsets_Click:
MsgBox Err.Description
Resume Exit_cmdDisplayOpenRequsets_Click
End Sub
"
When user clicks on "Display Open Requests" I want "subfrmRequests" to display only the "open" requests, so I have created "qryOpenRequests" where the criteria for the "Requests_Status" is ="open". And in the coding I have tried to set the recordsource for "subfrmRequests" to "qryOpenRequests".
However this is not working. When I click on "Display Open Requests" it is still displaying requests with a "closed" status.
Is there something wrong with the command button coding for setting the sub form's record source (as in the above code)?