Results 1 to 13 of 13

Thread: Hide Button

  1. #1
    Join Date
    Mar 2004
    Location
    Greenville, SC
    Posts
    271

    Unanswered: Hide Button

    I want to hide a button on my form when the record is new. How can I add this to my code of the button??

    Here is the code now:
    Private Sub Command876_Click()
    DoCmd.RunCommand acCmdSelectRecord
    DoCmd.RunCommand acCmdCopy
    DoCmd.RunCommand acCmdPasteAppend
    End Sub

    This copies data from one record onto a new blank form. Obviously I don't want to copy blank info into a new form.

    Any help would be greatly appreciated!
    Michael
    Gotta to do some code

  2. #2
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Read about the "visible" property of a button/object.
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  3. #3
    Join Date
    Mar 2004
    Location
    Greenville, SC
    Posts
    271
    Where should I read about this??

    Read about the "visible" property of a button/object.
    Michael
    Gotta to do some code

  4. #4
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Access help files.

    Here's a sample from said file:

    You can use the Visible property to show or hide a form, report, form or report section, or control. This may be useful if you want to maintain access to information on a form without it being visible. For example, you could use the value of a control on a hidden form as the criteria for a query.
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  5. #5
    Join Date
    Mar 2004
    Location
    Greenville, SC
    Posts
    271
    I can get a button to be invisible. I am not having any luck making the button not visible when I am in a blank or new record.

    Is there a way for me to make a button not visible say when my text box "Company" is empty. This way I know on a new record there would be no Company, and my button would be invisible. Then when I type something in the Company text box, My button would appear.

    Any help writing this in code would be greatly appreciated!!

    Michael
    Gotta to do some code

  6. #6
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    More reading ...

    This time check out the OnCurrent Event.
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  7. #7
    Join Date
    Mar 2004
    Location
    Greenville, SC
    Posts
    271
    I did exactly that with no luck!

    Here is the code I entered in the On Current:
    Private Sub Form_Current()
    If Me.NewRecord Then
    Me!CopySample.Visible = False
    End If
    End Sub
    The button never shows???????

    What am I missing?

    Michael
    Gotta to do some code

  8. #8
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    You have to set it to true if your condition fails

    Code:
    If ConditionToHideButton = True Then
       button.visible = False
    Else
       button.visible = True
    End If
    I'm not sure if form.newrecord returns whether your on a new record or not? I guess I have some reading to do now... lol
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  9. #9
    Join Date
    Mar 2004
    Location
    Greenville, SC
    Posts
    271
    Teddy, Thank you for your patience. It still will not show my button now. Here is the code I have.

    Code:
     
    
    Private Sub Form_Current()
    	If Me.NewRecord = True Then
       Me!CopySample.Visible = False
       Else
       Me!CopySample.Visible = False
       End If
    End Sub
    I am really trying, I just am still green at this coding stuff!!
    Thank You,
    Michael
    Gotta to do some code

  10. #10
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Read through that code again...

    Hint: At what point have you set .visible = True?
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  11. #11
    Join Date
    Mar 2004
    Location
    Greenville, SC
    Posts
    271
    I feel like an idiot!!

    Thank You so much! It works great.

    I had a macro originally in my On Current to go to my "Company" control each time. Would I enter this like:

    Code:
     
    Private Sub Form_Current()
    If Me.NewRecord = True Then
       Me!CopySample.Visible = False
       Else
       Me!CopySample.Visible = True
       End If 
       DoCmd.GoToControl "Company"  or (Company) or does it matter?
    End Sub
    Thank You again Teddy,
    Michael
    Gotta to do some code

  12. #12
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Go with the quoted "Company"
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  13. #13
    Join Date
    Mar 2004
    Location
    Greenville, SC
    Posts
    271
    Thank You ever so much for your help!!!!!

    Michael
    Gotta to do some code

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •