Results 1 to 8 of 8

Thread: Help of all experts needed

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2002
    Location
    India
    Posts
    4

    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

  2. #2
    Hyperactive Member Paul Warren's Avatar
    Join Date
    Jun 2000
    Location
    UK
    Posts
    282
    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.

  3. #3

    Thread Starter
    New Member
    Join Date
    Aug 2002
    Location
    India
    Posts
    4
    The Error is

    Compiler Error:
    Can't assign to read only property

  4. #4
    Hyperactive Member Paul Warren's Avatar
    Join Date
    Jun 2000
    Location
    UK
    Posts
    282
    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.

  5. #5

    Thread Starter
    New Member
    Join Date
    Aug 2002
    Location
    India
    Posts
    4
    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

  6. #6

    Thread Starter
    New Member
    Join Date
    Aug 2002
    Location
    India
    Posts
    4
    ANY ONE PLS HELPANY ONE PLS HELP

  7. #7
    Hyperactive Member Paul Warren's Avatar
    Join Date
    Jun 2000
    Location
    UK
    Posts
    282
    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.

  8. #8
    Frenzied Member swatty's Avatar
    Join Date
    Aug 2002
    Location
    somewhere on earth
    Posts
    1,478

    Non expert reply

    Replace your code
    VB Code:
    1. Public Sub Disabling()
    2. Dim str As String
    3. Dim rs As rdoResultset
    4. Set rs = gbon.OpenResultset("Select menuName from FormsControls " & _
    5. "Where Data='0'", rdOpenStatic, rdConcurValues)
    6. While rs.EOF = False
    7.   str = rs.rdoColumns(0)
    8.   Me.Controls(str).Enabled = False
    9.   rs.MoveNext
    10. Wend
    11. 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
  •  



Click Here to Expand Forum to Full Width