By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,703 Members | 1,681 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,703 IT Pros & Developers. It's quick & easy.

Can a command button on an Access 2007 form be conditionally displayed?

P: 2
I recently began working with Access 2007, but I do have a limited experience with prior versions.

I have a form with a button whose visibility I would like to make conditional on the Month value of Now(). I would like the test to be done any time the form is displayed. I have been unable to find any macros or VBA code examples showing me how to accomplish this, so I'm beginning to wonder if it can be done. In simple pseudo code, here's what I'd like to do:

Expand|Select|Wrap|Line Numbers
  1. If(Month(Now())=1,Button.Visible=True, If(Month(Now())=12,Button.Visible=True,Button.Visible=False))
Is something like this possible to do in Access 2007?

Thanks for looking.

Dave Anderson
Bismarck ND
Jul 26 '10 #1
Share this Question
Share on Google+
2 Replies

Expert Mod 15k+
P: 31,769
Certainly David.

Include this code as your form's Open event procedure :
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Open()
  2.     Me.Button.Visible = ((Month(Date) = 1) Or (Month(Date) = 12))
  3. End Sub
Jul 26 '10 #2

P: 2
Something so simple? Thank you for the response-I will try this first thing tomorrow.
Jul 27 '10 #3

Post your reply

Sign in to post your reply or Sign up for a free account.