Hiding a button based on a value in a table

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
 
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

I'm Using Access 2003
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top