Enable/Disable Buttons based on Data

matthewnsarah07

Registered User.
Local time
Today, 02:22
Joined
Feb 19, 2008
Messages
192
This might be tricky or easy to do I'm not sure, so here goes!

I am setting a database which monitors checks carried out on staff once per quarter when managers ensure staff vehicles and equipment are checked properly.

Currently I have a table of manager tblTM and one of staff tblstaff, the managers are linked to their staff via a one to many relationship via field [TMID].

On the opening form the managers name is collected and a subform based on a query displays that managers staff on continuous forms - frmsubtmview.

I then have button next to each member of staff which open a small popup form which passes details on the check carried out to tblppe. As only one check is required per quarter I would like the button next to a staff members name to be disabled once a check is completed (or possibly a box indicating that a check has been done)

How would I go about this - the dates of the current quarter are held on the form in [Date From] & [Date To]

Any ideas how to start this??
 
There are probably many ways, but one way is to perhaps have a query that does this check for you. Then on the form's on open event or on current event you could do a DLookup and depending on the response from the query set the button to visible or not. Or just set the DLookup to look it up in the table with multiple criteria to make the determination.

-dk
 
Thanks for your advice

It would seem easy enough to set up a query to run in the background.

Assuming I did this method and had a query running it would basically have an entry for a member of staff or there would be no entry at all, how would the DLookup need to be formatted to take into account either data present or null
 
Okay, so let's say you have your query all done up and it makes reference to the form dates for the criteria. Also, let's say you have the TableID (I am assuming you have this because this button is looking for something specific) also as a column that references the form to check for the appropriate record you are looking for. so it will execute correctly if the form is open and you run it manually (I know you already knew this, but just wanted to remind you). :D

The IsNull function evaluates to a true or false so the statement would look something similar to the following ...

Code:
If IsNull(DLookup("TableID", "qryQueryName", "[TableID] = " & Me.txtFormControlTableID) = True
     MsgBox "There is no quarterly thingee."
Else
     'do whatever
End IF

-dK
 

Users who are viewing this thread

Back
Top Bottom