I have a database that tracks the amount of open technical issues in an engineering department. Open issues are called PunchItems.
I have a MAINFORM based on a table tblPUNCHITEMS with the following filed:
tblPunchItems
---------------
PunchItemID (AutoNumber)
Title (Text)
PersonAssignedTo (Number)
On the main form, there is a subform called COMMENTS that records comments from various engineers about the PunchItems. The COMMENTS subform is based on the table tblCOMMENTS with the following fields:
tblComments
-------------
CommentID (AutoNumber)
PunchItemID (Number)
PersonCommentingID (Number)
Comments (Memo)
Now when I open the mainform directly (without code) the subform comes up displaying the correct comments for a particular punchitem.
PROBLEM is when I created a form called DIALOGUEFORM so that a user could select an employee from a combo box called EMPLOYEENAME and then click on a command button called ShowHisIssues to open the MIANFORM. The MAIN FORM would be filtered to show only the punch items assigned to the selected employee.
PROBLEM:
After selecting the employee and clicking on the ShowHisIssues button, the main form comes up, correctly filtered BUT WITH THE SUBFORM NOT DISPLAYED ie BLANK.
I have pasted the code for the on clock event of the ShowHisIssues button.
WHERE HAVE I GONE WRONG?? Never had this problem before.
Any help/Advice will be appreciated.
--------------------------------------
Private Sub ShowHisIssues_Click()
On Error GoTo Err_ShowHisIssues_Click
Dim stDocName As String
Dim stLinkCriteria As Variant
' Check if user entered a name.
If IsNull(EmployeeName) Then
DisplayMessage "You must select or enter your name."
EmployeeName.SetFocus
Exit Sub
End If
stDocName = "MAINFORM"
stLinkCriteria = "[PersonAssignedTo]=" & Me![EmployeeName]
' Check whether the user has any issues. If they do, open the Issues
' form with a filter; otherwise, open it without a filter.
If DCount("PunchItemID", "tblPunchItems", stLinkCriteria) Then
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
DisplayMessage "No issues assigned to you -- displaying all issues."
DoCmd.OpenForm stDocName
End If
' Close the dialog box.
DoCmd.Close acForm, "DialogueForm"
Exit_ShowHisIssues_Click:
Exit Sub
Err_ShowHisIssues_Click:
MsgBox Err.Description
Resume Exit_ShowHisIssues_Click
End Sub
------------------------------------
Thanks,
ZaZa
I have a MAINFORM based on a table tblPUNCHITEMS with the following filed:
tblPunchItems
---------------
PunchItemID (AutoNumber)
Title (Text)
PersonAssignedTo (Number)
On the main form, there is a subform called COMMENTS that records comments from various engineers about the PunchItems. The COMMENTS subform is based on the table tblCOMMENTS with the following fields:
tblComments
-------------
CommentID (AutoNumber)
PunchItemID (Number)
PersonCommentingID (Number)
Comments (Memo)
Now when I open the mainform directly (without code) the subform comes up displaying the correct comments for a particular punchitem.
PROBLEM is when I created a form called DIALOGUEFORM so that a user could select an employee from a combo box called EMPLOYEENAME and then click on a command button called ShowHisIssues to open the MIANFORM. The MAIN FORM would be filtered to show only the punch items assigned to the selected employee.
PROBLEM:
After selecting the employee and clicking on the ShowHisIssues button, the main form comes up, correctly filtered BUT WITH THE SUBFORM NOT DISPLAYED ie BLANK.
I have pasted the code for the on clock event of the ShowHisIssues button.
WHERE HAVE I GONE WRONG?? Never had this problem before.
Any help/Advice will be appreciated.
--------------------------------------
Private Sub ShowHisIssues_Click()
On Error GoTo Err_ShowHisIssues_Click
Dim stDocName As String
Dim stLinkCriteria As Variant
' Check if user entered a name.
If IsNull(EmployeeName) Then
DisplayMessage "You must select or enter your name."
EmployeeName.SetFocus
Exit Sub
End If
stDocName = "MAINFORM"
stLinkCriteria = "[PersonAssignedTo]=" & Me![EmployeeName]
' Check whether the user has any issues. If they do, open the Issues
' form with a filter; otherwise, open it without a filter.
If DCount("PunchItemID", "tblPunchItems", stLinkCriteria) Then
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
DisplayMessage "No issues assigned to you -- displaying all issues."
DoCmd.OpenForm stDocName
End If
' Close the dialog box.
DoCmd.Close acForm, "DialogueForm"
Exit_ShowHisIssues_Click:
Exit Sub
Err_ShowHisIssues_Click:
MsgBox Err.Description
Resume Exit_ShowHisIssues_Click
End Sub
------------------------------------
Thanks,
ZaZa