Check and Increase count

E

Eric G

I just added a [CLCount] field to my Staff table.
When a staff's UserID and Password is entered into the Password form
and they click on the OK button, I would like two things to happen:

1. Check the CLCount field for that staff's UserID to see if it's <4,
and if so, do XYZ.
2. Increase the UserID's CLCount field by +1.

Would someone be able to tell me the VB code required to accomplish
the two above steps?

Thanks in advance! Eric
 
P

PC Datasheet

Put this code in the Click event of the button:

If IsNull(Me!CLCount) Or Me!ClCount < 4 Then
<<Do XYZ >>
End If
Me!CLCount = Me!CLCount +1
 
E

Eric G

Thanks for helping out.
It looked like your code would be too simple to work out for my
situation and I fear that it is.

Nothing is happening when I click the OK button now.

How does your code allow my db to realise that UserID "x" in Table
[Teachers] needs their CLCount number to be checked and then increased
by one?
I don't see how Me! tells the app to refer to a table that isn't open
at the time.

I was using the following code up until now:
'If DCount("[DateDet]", "Detentions", "[TeacherID]='" & [cboUserID] &
"'") < 4 Then
'DoCmd.OpenForm "frmCheckList"

and although it does work, it relies on an ever-growing table
[Detentions] to pull up a number to compare with 4.

Now I'd just like to compare 4 to the new CLCount number in the
Teachers table.

Thanks! Eric
 

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