Solved

Make Command button visible or not

Posted on 2004-10-05
6
491 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
  • 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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

758 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now