Hiding a button based on a value in a table

  • Thread starter Thread starter Colin Walls
  • Start date Start date
C

Colin Walls

Hi Guys,

Been going round and round on this fairly simple thing.

All I want is for a button to be greyed out on a form if the week number exists in a table.

I've got a a table called week which has the column headings ID:DATE:WEEK
2 buttons:
Button1
Button2
And a form called "disablebuttons"

In my head this should happen:
When the form is opened and On Current event should run.
This event should look for the current date in the DATE column in table "week" then return that WEEK number.
Based on that it should then disable or enable a "button1" on the form.

This is what I have so far (I'm not exactly well versed in VBA):

Private Sub Form_Current()
If DCount("Week", "week") = "58" Then "<- this is the line annoying me"
Me.Button1.Enabled = False
Else
Me.Button1.Enabled = True
End If
End Sub

Any help would be greatly appreciated.

Cheers,
Colin
 
Hi Guys,



Been going round and round on this fairly simple thing.



All I want is for a button to be greyed out on a form if the week number exists in a table.



I've got a a table called week which has the column headings ID:DATE:WEEK

2 buttons:

Button1

Button2

And a form called "disablebuttons"



In my head this should happen:

When the form is opened and On Current event should run.

This event should look for the current date in the DATE column in table "week" then return that WEEK number.

Based on that it should then disable or enable a "button1" on the form.



This is what I have so far (I'm not exactly well versed in VBA):



Private Sub Form_Current()

If DCount("Week", "week") = "58" Then "<- this is the line annoying me"

Me.Button1.Enabled = False

Else

Me.Button1.Enabled = True

End If

End Sub



Any help would be greatly appreciated.



Cheers,

Colin

I'm Using Access 2003
 
Back
Top