Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I change command button properties from another form?

Status
Not open for further replies.

jac123

Technical User
Apr 25, 2003
19
US
I have a form for the user to select the type of DB form he wishes. There are two Options.
If the user selects the first command button, it will
take him to the switchboard form. I would also like it to enable the second command button (Option2) on the switchboard form.

Private Sub CmdButton_Click()
Dim strControl As String
Dim strDocName As String
strControl = "Option2"
DoCmd.OpenForm strDocName
Option2.Enable = False

(When I run this it states: Object variable or with block variable not set). Please help
 
Just do this .....

Form2.Option2.Enable = True

Substitute your form name for form2.
 
Hi vbrocks..
When I do the above I get an error message saying
"Variable Not Defined". That command must not be able
to locate the Form2 "Switchboard".
Any other suggestions?

Thanks
 
Private Sub CmdButton_Click()
Dim strControl As String
Dim strDocName As String
strControl = "Option2"
strDocName = "Switchboard"
DoCmd.OpenForm strDocName
Option2.Enable = True
 
VBrock - Below I copied my event procedure from the CmdButton Click event. When I run this code a message is
returned stating (Ambiguous name detected: Option2). Not
sure what is happening.

Private Sub CmdButton_Click()
On Error GoTo Err_CmdButton_Click
Dim strControl As String
Dim strDocName As String
strControl = "Option2"
strDocName = "Switchboard"
DoCmd.OpenForm strDocName
Option2.Enable = True


Exit_CmdButton_Click:
Exit Sub

Err_CmdButton_Click:
MsgBox Err.Description
Resume Exit_CmdButton_Click

End Sub

 
Why do you have ....
strControl = "Option2"
It does not serve a purpose in the above procedure.
You may have to declare strControl as a public variable ...
If you use it somewhere else.
 
You can change everything from even who logins in...e.g

if username admin then

main.caption = "Admin user"
Form6.Caption = "Admin User"
Form12.Command1.Caption = "Test"
Form16.Option1.Enabled = False

Else

main.caption = "User"
Form6.Caption = "User"
Form12.Command1.Caption = "Cool"
Form16.Option1.Enabled = True

End if
 
Have you tried

Switchboard.Option2.Enabled = False

Danielgraham, what are you on about??
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top