|
-
Aug 19th, 2002, 02:42 AM
#1
Thread Starter
New Member
Help of all experts needed
I'm critically in a project and facing a problem
PROBLEM:
I have an MDI form And had 5 menus
Caption Name
Eg Menu1 -mnuMenu1
Menu2 -mnuMenu2
I'm storing the name of menus into a table.On the loading event of the MDIForm i will Collect the the menu Name .with that Menu name collected i want to enable or disable the menu depending on some conditions.But it is not working.
See my code
Public Sub Disabling()
Dim str As Menu
Dim rs As rdoResultset
Set rs = gbon.OpenResultset("Select menuName from FormsControls " & _
"Where Data='0'", rdOpenStatic, rdConcurValues)
While rs.EOF = False
str.Name = rs.rdoColumns(0)
str.Enabled = False
rs.MoveNext
Wend
End Sub
Pls Help me
-
Aug 19th, 2002, 03:06 AM
#2
Hyperactive Member
When you say it's not working what do you mean? What happens when you run the code?
That's Mr Mullet to you, you mulletless wonder.
-
Aug 19th, 2002, 03:27 AM
#3
Thread Starter
New Member
The Error is
Compiler Error:
Can't assign to read only property
-
Aug 19th, 2002, 03:37 AM
#4
Hyperactive Member
I think you should be using the Caption property, not Name? You can't rename stuff at runtime so that's what I'd expect to be the cause of the problem.
That's Mr Mullet to you, you mulletless wonder.
-
Aug 19th, 2002, 03:44 AM
#5
Thread Starter
New Member
Originally posted by Paul Warren
I think you should be using the Caption property, not Name? You can't rename stuff at runtime so that's what I'd expect to be the cause of the problem.
How can i manipulate the properties of the control by using the Caption
-
Aug 19th, 2002, 04:09 AM
#6
Thread Starter
New Member
ANY ONE PLS HELPANY ONE PLS HELP
-
Aug 19th, 2002, 04:35 AM
#7
Hyperactive Member
After an extensive 5 second search of MSDN I found this:
Creating a Menu Control Array
A menu control array is a set of menu items on the same menu that share the same name and event procedures. Use a menu control array to:
Create a new menu item at run time when it must be a member of a control array. The MDI Notepad sample, for example, uses a menu control array to store a list of recently opened files.
Simplify code, because common blocks of code can be used for all menu items.
Each menu control array element is identified by a unique index value, indicated in the Index property box on the Menu Editor. When a member of a control array recognizes an event, Visual Basic passes its Index property value to the event procedure as an additional argument. Your event procedure must include code to check the value of the Index property, so you can determine which control you're using.
For More Information For more information on control arrays, see "Working with Control Arrays" in "Using Visual Basic's Standard Controls."
To create a menu control array in the Menu Editor
Select the form.
From the Tools menu, choose Menu Editor.
–or–
Click the Menu Editor button on the toolbar.
In the Caption text box, type the text for the first menu title that you want to appear on the menu bar.
The menu title text is displayed in the menu control list box.
In the Name text box, type the name that you will use to refer to the menu control in code. Leave the Index box empty.
At the next indentation level, create the menu item that will become the first element in the array by setting its Caption and Name.
Set the Index for the first element in the array to 0.
Create a second menu item at the same level of indentation as the first.
Set the Name of the second element to the same as the first element and set its Index to 1.
Repeat steps 5 – 8 for subsequent elements of the array.
Important Elements of a menu control array must be contiguous in the menu control list box and must be at the same level of indentation. When you're creating menu control arrays, be sure to include any separator bars that appear on the menu.
I suggest you have a look around for more information. I just haven't got time to work it all out for you. Hope this helps.
That's Mr Mullet to you, you mulletless wonder.
-
Aug 19th, 2002, 06:05 AM
#8
Frenzied Member
Non expert reply
Replace your code
VB Code:
Public Sub Disabling()
Dim str As String
Dim rs As rdoResultset
Set rs = gbon.OpenResultset("Select menuName from FormsControls " & _
"Where Data='0'", rdOpenStatic, rdConcurValues)
While rs.EOF = False
str = rs.rdoColumns(0)
Me.Controls(str).Enabled = False
rs.MoveNext
Wend
End Sub
Code:
If Question = Incomplete Then
AnswerNextOne
Else
ReplyIfKnown
End If
cu Swatty
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|