Solved

Make Command button visible or not

Posted on 2004-10-05
6
496 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 500 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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

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.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

691 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