Hi. I have a form with multiple pages and about a hundred or so fields. Based upon the selection of one combo box, I want to make different fields and pages visible or not visible.
I got one of the pages (CurrentResources) to switch from visible to not visible using an onchange macro on the combo box (txtOpportunityStatus) and an oncurrent macro on the actual form (form). However, when I tried to add more controls to show/hide, it would still only work on that first page I put in. Is is possible to add multiple control names to one macro since multiple macros wouldn't work? I'm not sure if it matters, but I have tried making the original 'visible' property of the controls I'd like to change both true and false.
I also tried changing the macros into VBA (I work with a lot of Access forms, but usually don't write much VBA), but I still can't get it to work. I'm not getting any errors so I don't know if my coding is incorrect or if I'm just way off base. The VBA code I tried for the onchange is below (I would just repeat for the oncurrent of the form):
Thanks so much for your help,
Staci
Staci – Using Windows 7, Microsoft Office 2007 & Crystal Reports Version 10
I got one of the pages (CurrentResources) to switch from visible to not visible using an onchange macro on the combo box (txtOpportunityStatus) and an oncurrent macro on the actual form (form). However, when I tried to add more controls to show/hide, it would still only work on that first page I put in. Is is possible to add multiple control names to one macro since multiple macros wouldn't work? I'm not sure if it matters, but I have tried making the original 'visible' property of the controls I'd like to change both true and false.
I also tried changing the macros into VBA (I work with a lot of Access forms, but usually don't write much VBA), but I still can't get it to work. I'm not getting any errors so I don't know if my coding is incorrect or if I'm just way off base. The VBA code I tried for the onchange is below (I would just repeat for the oncurrent of the form):
Code:
Private Sub txtOpportunityStatus_Change()
On Error GoTo txtOpportunityStatus_Change_Err
If (txtOpportunityStatus = "Closed") Then
DoCmd.SetProperty "ContractResources", acPropertyVisible, "-1"
DoCmd.SetProperty "Contract#", acPropertyVisible, "-1"
DoCmd.SetProperty "Label174", acPropertyVisible, "-1"
DoCmd.SetProperty "Solicitation#", acPropertyVisible, "0"
DoCmd.SetProperty "Label71", acPropertyVisible, "0"
End If
If (txtOpportunityStatus = "Active") Then
DoCmd.SetProperty "ContractResources", acPropertyVisible, "-1"
DoCmd.SetProperty "Contract#", acPropertyVisible, "-1"
DoCmd.SetProperty "Label174", acPropertyVisible, "-1"
DoCmd.SetProperty "Solicitation#", acPropertyVisible, "0"
DoCmd.SetProperty "Label71", acPropertyVisible, "0"
End If
If (txtOpportunityStatus = "New") Then
DoCmd.SetProperty "ContractResources", acPropertyVisible, "0"
DoCmd.SetProperty "Contract#", acPropertyVisible, "0"
DoCmd.SetProperty "Label174", acPropertyVisible, "0"
DoCmd.SetProperty "Solicitation#", acPropertyVisible, "-1"
DoCmd.SetProperty "Label71", acPropertyVisible, "-1"
End If
If (txtOpportunityStatus = "Pending") Then
DoCmd.SetProperty "ContractResources", acPropertyVisible, "0"
DoCmd.SetProperty "Contract#", acPropertyVisible, "0"
DoCmd.SetProperty "Label174", acPropertyVisible, "0"
DoCmd.SetProperty "Solicitation#", acPropertyVisible, "-1"
DoCmd.SetProperty "Label71", acPropertyVisible, "-1"
End If
txtOpportunityStatus_Change_Exit:
Exit Sub
txtOpportunityStatus_Change_Err:
MsgBox Error$
Resume txtOpportunityStatus_Change_Exit
End Sub
Thanks so much for your help,
Staci
Staci – Using Windows 7, Microsoft Office 2007 & Crystal Reports Version 10