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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

setting form properties doubt

Status
Not open for further replies.

LuckyStarr

Programmer
Sep 12, 2002
22
BR
Hi guys,

I would be glad if you could answer my question.

I have a form, with a menu named mnuSave. Besides that, I have a source code file, named OFCVB.bas .

Now, I want mnuSave to have its "enabled" property set to True when something happens inside OFCVB.bas .

I'm trying this: frmFCT.mnuSave.enabled = True
However, the menu is not enabled after that!

The watch window shows: "Object variable or With Block variable not set".

Do I have to initialize something before?

Can you help me please? Thanks!
 

Here's a simple routine I use to enable/disable menu items (based on the menu item's caption):

' Use: EnableMenu frmMain, "Save", False

Public Sub EnableMenu(frm As Form, strCaption As String, blnEnable As Boolean)
On Error GoTo err_handler
Dim ctl As Control
Dim objMenu As Menu
For Each ctl In frm.Controls
If TypeOf ctl Is Menu Then
Set objMenu = ctl
If UCase(Trim(objMenu.Caption)) = UCase(Trim(strCaption)) Then
objMenu.Enabled = blnEnable
Exit For
End If
End If
Next
err_exit:
Exit Sub
err_handler:
MsgBox "The following error has occurred: EnableMenu failed on Form " & frm.Name & vbNewLine & _
Err.Description, vbCritical, "Error"
Resume err_exit
End Sub

Mark

"You guys pair up in groups of three, then line up in a circle."
- Bill Peterson, a Florida State football coach
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top