[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Make Command button visible or not

Posted on 2004-10-05
6
Medium Priority
?
498 Views
Last Modified: 2012-05-05
Hi All,

Hopefully this is an easy one.

I have a main menu form (the Switchboard).
On that form is a command button (cmdImport) that is not visible on form open.
When you double-click the logo graphic (imgLogo), the cmdImport button is visible.
When you click the command button it takes you to another form (one for importing records)
After you have finished importing records, you click and exit command button and you return to the main menu (Switchboard)
The problem is, when you return to the main menu the cmdImport button is still visible... I'd like for it to be invisible again... like it was on form open.

Here's some of my code...

----------On Open - main menu form-------------------------------------------------
Private Sub Form_Open(Cancel As Integer)
' Minimize the database window and initialize the form.

    ' Minimize the database window.
    'DoCmd.SelectObject acForm, "Switchboard", True
    'DoCmd.Hide

    ' Move to the switchboard page that is marked as the default.
    Me.Filter = "[ItemNumber] = 0 AND [Argument] = 'Default' "
    Me.FilterOn = True
    cmdImport.Visible = False
End Sub

-----------On Double-Click - main menu form ---------------------------------------
Private Sub imgLogo_DblClick(Cancel As Integer)
    cmdImport.Visible = True
End Sub

-----------On Open - import form ----------------------------------------------------
Private Sub Form_Open(Cancel As Integer)
    If IsLoaded("Switchboard") Then
        [Forms]![Switchboard].Visible = False
    End If
End Sub
-----------On Close - import form ----------------------------------------------------
Private Sub Form_Close()
    If IsLoaded("Switchboard") Then
        [Forms]![Switchboard].Visible = True
    End If
End Sub

I'm assuming I need to put "cmdImport.Visible = False"
Somewhere, but I can't figure out under what event.. and on which form.

Any ideas?

TIA,
Die-Tech

0
Comment
Question by:Die-Tech
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 36

Accepted Solution

by:
SidFishes earned 2000 total points
ID: 12229976
just put

forms!yourFormNAme!cmdImport.Visible = False

at the  end of your import procedure or in the exit_click event of your import form
0
 
LVL 10

Expert Comment

by:ALaRiva
ID: 12229988
I'd say to keep with your logic flow, you have two options,

Option 1 you can put it under the Click Event of the cmdImport
---For this option put it as the last line of code in the event----

Option 2 you can put it under the Close Event of the Import Form


HTH

-Anthony
0
 
LVL 4

Author Comment

by:Die-Tech
ID: 12230130
Ok.. when I do that I get the following error message.

You can't hide a control that has the focus.

Does this mean the cmdImport button on the Switchboard form had the focus (because we just clicked it to open the import form) and when we go back to the Switchboard the cmdImport button still has the focus so you can't make it invisible?

If that's right, I guess I need to change the focus on the Switchboard form to something other than the cmdImport button after you click the cmdImport button and before it opens the import form.

0
Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

 
LVL 4

Author Comment

by:Die-Tech
ID: 12230207
SidFishes,

I was able to get it working.

I put the following in the cmdImport_click just before it opens the Import form
    Option1.SetFocus

Now when I come back to the Switchboard from the Import form, I don't get any errors and the cmdImport button is invisible.

THanks,
Die-Tech
0
 
LVL 10

Expert Comment

by:ALaRiva
ID: 12230234
Oops, Sorry about that, you'll need to put the code in the close event of the Import Form.

-----------On Close - import form ----------------------------------------------------
Private Sub Form_Close()
    If IsLoaded("Switchboard") Then
        [Forms]![Switchboard].Visible = True
    End If
    Forms!Switchboard!cmdImport.Visible = False
End Sub


I have no idea why I was trying to offer putting it in the Click Event of the button itself.

HTH

-Anthony
0
 
LVL 4

Author Comment

by:Die-Tech
ID: 12230376
ALaRiva,

I tried what you mentioned above and got the same error message
"You can't hide a control that has the focus."

I think the problem is the cmdImport button had the focus when we left the Switchboard to go to the Import form.
After leaving the Import form, going back to the Switchboard the cmdImport button still has the focus so it won't let the control be invisible.

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question