D
Donna
Help! I have been trying to get the following to work for hours and keep getting the error message that the OpenForm action was cancelled...
I am trying to get a new form to open based on the selection from a list box. This is the second such screen within the database.
I can get the first one to work, but I'm stuck...
Any help would be greatly appreciated (P.S. I am a complete novice at Access - this is my first database design.) Thanks
Private Sub cmdView_Click(
Dim strWhere As String, varItem As Varian
' If no items selected, then nothing to d
If Me!lstProjName.ItemsSelected.Count = 0 Then Exit Su
' Loop through the items selected collectio
For Each varItem In Me!lstProjName.ItemsSelecte
' Grab the Project ID for each selected ite
strWhere = strWhere & Chr$(34) & Me!lstProjName.Column(0, varItem) & Chr$(34) & ",
Next varIte
' Throw away the extra comma on the "IN" strin
strWhere = Left$(strWhere, Len(strWhere) - 1
' Open the projects form filtered on the selected project
gstrWhereProject = "[ProjectID] IN (" & strWhere & ")
DoCmd.OpenForm FormName:="frmProjects", WhereCondition:=gstrWhereProjec
' Hide the subform, but show the slection list and hide button
Forms!frmProjects!Phasesubform.Visible = Fals
Forms!frmProjects!cmdReturn.Visible = Fals
DoCmd.RunCommand acCmdSaveRecor
End Su
I am trying to get a new form to open based on the selection from a list box. This is the second such screen within the database.
I can get the first one to work, but I'm stuck...
Any help would be greatly appreciated (P.S. I am a complete novice at Access - this is my first database design.) Thanks
Private Sub cmdView_Click(
Dim strWhere As String, varItem As Varian
' If no items selected, then nothing to d
If Me!lstProjName.ItemsSelected.Count = 0 Then Exit Su
' Loop through the items selected collectio
For Each varItem In Me!lstProjName.ItemsSelecte
' Grab the Project ID for each selected ite
strWhere = strWhere & Chr$(34) & Me!lstProjName.Column(0, varItem) & Chr$(34) & ",
Next varIte
' Throw away the extra comma on the "IN" strin
strWhere = Left$(strWhere, Len(strWhere) - 1
' Open the projects form filtered on the selected project
gstrWhereProject = "[ProjectID] IN (" & strWhere & ")
DoCmd.OpenForm FormName:="frmProjects", WhereCondition:=gstrWhereProjec
' Hide the subform, but show the slection list and hide button
Forms!frmProjects!Phasesubform.Visible = Fals
Forms!frmProjects!cmdReturn.Visible = Fals
DoCmd.RunCommand acCmdSaveRecor
End Su