Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 1st, 2006, 11:44 AM
Friend of Wrox
 
Join Date: May 2006
Posts: 144
Thanks: 0
Thanked 0 Times in 0 Posts
Default visible/invisible

hi again,
one more thing I'm getting stuck on. I want to hide a button when it is clicked. But, the Visible property will not work for me b/c the button that has focus cannot be hidden. Is there another command for this?

Private Sub btnLock_Click()
    Dim Answer As VbMsgBoxResult
    Answer = MsgBox("Are you sure you want to lock line setup?", vbYesNo, "Lock Options")
    If Answer = 6 Then
        btnParameters.Visible = False
        btnFill.Visible = False
        Command1.Visible = False
        Label3.Visible = False
        Label25.Visible = False
        Label12.Visible = False
        btnUnlock.Visible = True
        btnLock.Visible = False (this is where problem is)
    End If
End Sub

 
Old December 1st, 2006, 03:51 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Create a public variable in a module to hold a boolean. The default value for a boolean variable is False.

Reset the focus at the end of the If Then statement to another likely control and set the boolean to True.

Then set the form's On Current property to check the public variable. If it = true, which it only will after this routine, then make the button invisible.

Did that work?

mmcdonal
 
Old December 1st, 2006, 03:54 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Alternatively, if this is a bound form, create an additional column in the table, and make it Yes/No. Then at the end of your routine, set this column to Yes (No is the default) and check it On Current. This will allow you to keep the same formatting as you move from one record to the next.

You will still need to set a public variable to make this happen right away, probably.



mmcdonal
 
Old December 1st, 2006, 05:17 PM
Friend of Wrox
 
Join Date: May 2006
Posts: 144
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the response!

I'll give this a try.

 
Old December 1st, 2006, 05:40 PM
Friend of Wrox
 
Join Date: May 2006
Posts: 144
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Well I didn't get the boolean variable to work for me. But you did point me in the right direction. I had to change the focus, so I added this If statement directly after the other one:

Code:
    If Answer = 6 Then
    Forms!Main!btnUnlock.SetFocus
    btnLock.Visible = False
    End If


I didn't really think this would work since its still in the same click event, but it did so I'm going with it!

Thanks one again mmcdonal,

Dave








Similar Threads
Thread Thread Starter Forum Replies Last Post
Make visible/invisible stealthdevil Access VBA 6 May 31st, 2006 10:59 AM
visible vs. not visible on form akibaMaila VB.NET 2002/2003 Basics 2 August 15th, 2005 02:40 PM
invisible console app asmotritsky Visual C++ 1 November 25th, 2004 03:27 PM
Underscore to be invisible jmaronilla Beginning PHP 2 September 15th, 2004 09:37 AM
Invisible HyperLink acko ASP.NET 1.x and 2.0 Application Design 2 January 19th, 2004 01:00 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.