VBA to make one of 2 text boxes visible based on date

Auburnsp

New member
Local time
Today, 04:55
Joined
May 8, 2012
Messages
7
I have an access 2010 form that has a date field and two textboxes.

Trying to only show 1 text box based on the date field.

Example:

If Date >= 10/1/2010 and Date <= 9/30/2011 then text box 1 is visible and text box 2 not visible

if Date >= 10/1/2011 and date <= 9/30/2012 then text box 2 is visible and text box 1 is not visible

This seems easy but no matter what I try I either get both text boxes visible or neither.

Any help out there?
 
Code:
If #2010-10-01# <= Me.txtDate And Me.txtDate <= #2011-09-30# Then
    Me.TextBox1.Visible = True
    Me.TextBox2.Visible = False
ElseIf #2011-10-01# <= Me.txtDate And Me.txtDate <= #2012-09-30# Then
    Me.TextBox1.Visible = False
    Me.TextBox2.Visible = True
End If
 

Users who are viewing this thread

Back
Top Bottom