Warn user When the Data Being Entered 3 times

mykil

My Life is Boring
Local time
Today, 18:36
Joined
Aug 16, 2011
Messages
117
Hi everyone. can you help me make this up. I am making a simple database for the computer laboratory in school (my place of work). Actually it is a Automated Logbook System. Here's the Problem. I want to make a form that will prompt me whenever I enter the data(ID number) of the user(student) 3 times already for the current week.

Do you have a code for this!!!
The message box will more likely prompt.
The Data already entered 3 times this week!!!


:banghead::banghead::banghead:
 
I'm low on the skills ladder but this might suit.

The form that you use for making the entries will be based on a table so it has a recordset. Each time you add a record check the recordsetclone.
Dim myCount
myCount = 0
With Me.RecordsetClone
.MoveFirst
Do While Not .EOF
If .fieldname1 = criteria2 Then myCount = myCount + 1
If myCount > 2 Then
MsgBox "It's more than 2"
Exit Do
End If
.MoveNext
Loop
End With
--------------------
Alternatively you could try DCount()
Dim myCounter
myCounter = DCount("*", "yourTable", "yourID = " & Me!IDonForm)
If myCounter > 2 Then
MsgBox "It's more than 2"
End If
------
Hope I'm not giving bad advice.
 
I would use the DCount() function as micks55 suggested, but you might want to expand the criteria statement so that it only counts records in the last week.
I would also suggest using the the code in the forms Before Update event as this can stop the record from being saved if that is required.
Post back if you need more specific help.
 
Good Day. It's been a while since i visited the forum . I just went through a long week vacation. :p. By the way, Thank you very much for all your reply. Now, I'm back to work . I'd tried your suggestions and use dcount() but ending up with nothing accomplished. I have attached my sample db. can you check it. So in the form frmlogin i want a message box to prompt when the student's idnumber is being entered 3 times. Please check the codes or modify it to correct. Thank You very much.

Honestly, I'm a slow learner.:o
 

Attachments

Hi Bob fitz. Here's the A2003 mdb format.. Thank you in advance Bob.
 

Attachments

Dim myCounter
myCounter = DCount("*", "yourTable", "yourID = " & Me!IDonForm)
If myCounter > 2 Then
MsgBox "It's more than 2"
End If
------

Hi Micks55! I've used this Code but having a problem with the records. instead of counting only the data with the same IDNUMBER it counts all the data. So When I entered the 4th data with different IDNUMBER the message box will prompt. I don't want it that way. I want to count only 1 IDNUMBER if it is being entered 3 times already. Thanks Very Much!!!:(
 
I took a look at this. I can't find where this DCount() is supposed to happen. What form is it on? Also, if you want to count how many times something happens in time you need to store a date/time value somewhere. Then, when the thing happens that you want to count, store the date and time that it happens, so you can count when it happened.
hth
 
I took a look at this. I can't find where this DCount() is supposed to happen. What form is it on? Also, if you want to count how many times something happens in time you need to store a date/time value somewhere. Then, when the thing happens that you want to count, store the date and time that it happens, so you can count when it happened.
hth

Thanks for your reply. It is on the login form. On the after update of StudentID field.
Please check the db that i have attached. Thank you very much for the help..:)
 

Attachments

After you hit the Create table button, Access show you a table with a single field: ID.
Use THIS field for IDs. Change the field name as you need (my approach is to name the table at plural - tblStudents - and the ID field at singular - ID_Student ).

I have the same question as Mark (lagbolt)... and two more:
1) What mean last week ? The week that start monday ? The last 7 days (including today) ? Or the week before the current one ?
2) What you really need from Access ?

  • A information ? "More than 2: 5". OK. Thank you. Now I'm informed
  • An warning ? "More than 2: 5 ; Should I add this record ?" Yes/No
  • An action ? "More than 2 ; The record will not be added to the DB". OK - Good for you !
 
Thank you for the Reply Mihail.
1) What mean last week ? The week that start monday ? The last 7 days (including today) ? Or the week before the current one ?

The current week starting on monday. Because I want to limit every students to use computer unit 3 times every week. So when I logged them up. and suppose to be their fourth time to log in it will prompt the user of the db.

  • An action ? "More than 2 ; The record will not be added to the DB". OK - Good for you !
Yes. Exactly...
 
Feel free to ask more.

PS.
For unknown reasons Access do not allow me to save in 2003 format (this is 2007)
 

Attachments

Here's a way I might approach this. . .
 

Attachments

@Mark
Always something to learn from you. Thank you !
I have a question, please:
I saw here and in my thread Classes / OCX (thank you, again) that you use a Property Get procedure.
I think that I understand how this work: As a function. Is it ?
On the other hand, I think that you have a good reason to use this Property Get instead of a "usual" function. Can you explain this reason(s) ? Here or in my thread. Thank you !
 
Mihail:
Yeah, when to use a property, to me, is not a science, but if I think of a member of an object as a value that should be self-evident, or directly available, then I commonly expose that as a property. In OOP a class is commonly thought of as having data and behaviours, and so I think of the "data" as being exposed by Properties, and I think of the "behaviours" as exposed by Functions and Subs.

So I guess in general, if a member of a class is not a behaviour, it should be a property.

Also notice that members you add to a class appear in intellisense, and that the icon presented is different for a Property, on the one hand, and Subs and Functions on the other, so that can give the future you some information as to what those members are for, when you create an instance of a class you wrote 2 years ago and you can't remember how to use it.

But it might be interesting too, to look at objects you know in the object browser. A DAO.Recordset exposes a Fields collection as a property, but it exposes GetRows() as a Function. Why? What I imagine is that GetRows() is an added on behaviour, something the recordset can go and do, but internally it probably uses its own Move methods, and Fields collection to construct the GetRows() array on the fly. So the recordset exposes Fields() as a native attribute of what the recordset is, but GetRows() is a request you put in for the recordset to go and do something for you.

Looking at how other people solved these problems in the Object Browser is really interesting. It gives a lot of hints if you want to design your own classes.
 
Something new to think in the next few weeks :)
Thank you !
 
Feel free to ask more.

PS.
For unknown reasons Access do not allow me to save in 2003 format (this is 2007)

Thank You Mihail for this post .It helps!!!
:eek::eek::eek: I was blown away by the message box!!! hehehe. All the teachers in our school are good. So I have to Change it. Thanks a lot.
 

Users who are viewing this thread

Back
Top Bottom