Results 1 to 2 of 2
  1. #1
    5 Star Lounger
    Join Date
    Feb 2001
    Location
    Louisville, Kentucky, USA
    Posts
    605
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Giving Focus (2000)

    Good Morning All,

    I will try to make a long story short. My table stores the names of my controls (trying to make my own menus). So for this example, my table has MyMenu1, MyMenu2, etc. it also has lblMenu1, lblMenu2, etc. OK...therefore, there are 3 fields in the table. Menu-which is the OBJECT in the DB, cboBoxName-NameOfComboBox and lblName-NameOfLable. This table of course is the recordsource for another combobox.

    Now. Most of everything is working nicely. For testing purposes, and that's where this is currently, not sure I will go this route yet. I have a couple of combo boxes on a form. One holds a list of reports, MENU1, one a list of forms, MENU2, one holds the name of COMBO BOXES, MENU3, i.e. MENU1, MENU2, MENU3. Currently, I have 2 cbo's with a LABLE over the top, and the FOLLOWING code set on the MOUSE MOVE event :

    Me.cboMenu1.SetFocus
    Me.cboMenu1.Dropdown

    This works nicely.......

    However,

    I wanted to try something different. I wanted to make all menu's (cbo's) invisible except for 1, MENU3, which lists all the menus. When the user selects, say FORMS, then that cbo, MENU2, would be visible, and the code above would still function. The following code is what I have currently but isn't working.

    Dim ctl As Control

    ctl = Me.cboMenu3.Column(1)

    With ctl
    .Visible
    End With

    DoCmd.GoToControl ctl

    I get "Object Variable With Block Not Set"*****with this line highlighted "ctl = Me.cboMenu3.Column(1).

    Again this is just IDEA stage, but something I would like to do, but if it's not doable, I can live without it. BUT I would appreciate the input as to why I can't set the focus to the control.

    Thanks.
    Roberta Price <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Giving Focus (2000)

    I can't say I understand what you're doing, but the line

    ctl = Me.cboMenu3.Column(1)

    causes an error for 2 reasons:

    1. ctl is an object; you must precede the assignment of an object with Set.
    2. Me.cboMenu3.Column(1) is a string (the name of a control); you can't set a control to be a string. You must use the Controls collection of the form. You can refer to a control as Me.Controls("ControlName").

    Set ctl = Me.Controls(Me.cboMenu3.Column(1))

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •