Enabled Button

  • Thread starter Thread starter Steven M. Britton
  • Start date Start date
S

Steven M. Britton

Why does this case the button to always be disabled?

Private Sub Form_Load()

Me.btnAppendOrders.Enabled = True

If Me.Date = Date Then
Me.btnAppendOrders.Enabled = False
Else
Me.btnAppendOrders.Enabled = True
End If


End Sub
 
Steven M. Britton said:
Why does this case the button to always be disabled?

Private Sub Form_Load()

Me.btnAppendOrders.Enabled = True

If Me.Date = Date Then
Me.btnAppendOrders.Enabled = False
Else
Me.btnAppendOrders.Enabled = True
End If


End Sub

Because you named a field/control the same as a built in function. Access
can't tell the difference between Me.Date and the function Date so they are
always equal.

Me.[Date] will probably fix it, but you *really* should rename that
field/control.
 
Could be because you are using a Reserved Word (Date) as your Field/Control
name, and using Reserved Words as Field/Control names, Object Names or
Variables may cause unexpected results. (In other words, in Access is
already using the word for something, you can't!)

Try changing it to OrderDate, StartDate or something else that's
descriptive.

Access has quite a list of Reserved Words which can be viewed at:

http://support.microsoft.com/default.aspx?scid=kb;en-us;286335



hth,
 
Back
Top