?
Solved

Make Command button visible or not

Posted on 2004-10-05
6
Medium Priority
?
497 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
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 
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

Technology Partners: 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

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Suggested Courses

741 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