Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DCount to Limit the Number of Records

Status
Not open for further replies.

tomcat21

Programmer
Jul 28, 2002
69
US
First of all, I apologize for the many posts relating to this, but I have searched as thouroghly as I can and I am drawing a blank.

I am trying to protect a DEMO application that I send out to prospective customers. I have it to where it shuts off after a certain date but I also want to limit the numnber of records that can be entered.

I also do not know much about code.

I have benn told that DCount is probably the best way to go.

Lets say I have a Table named Incident Report. I have numerous fields including an autonumber field named ID#.
I have a main switchboard that contains numerous command buttons that open each individual form. The name of this particular form is frmincident. I have it set to open to the next new record in the On Click event.

How would I limit the number of records to say fifty (50) records. If it exceeds 50 I would like for it to display a message to say the DEMO has expired, etc.

What would the exact code be? Where would I place the code, in the On Click of the command button, After Update of the switchboard, etc.? Do I need to create another field?

I would very much appreciate any help I could get.

Thanks in advance.


Thomas Bailey
tomcat@reportcop.com
 
Hi Thomas!

You can use code like this:

If DCount("[ID#]", "[Incident Report]") = 50 Then
Call MsgBox("This Demo has expired")
Else
DoCmd.OpenForm etc
End If

I think you would also want to put something similar in the AfterUpdate event of the form so your clients will have some warning. You may even want to use a warning message at about 40 records so they know it is coming.

hth


Jeff Bridgham
bridgham@purdue.edu
 
why not just base your forms on queries that will only retrieve the top 50 records and sort them in reverse order. that way they can still add records but it will be useless as only 50 will be retrieved

"My God! It's full of stars...
 
Also, I modified to instead of =50, to >50.

Plus, it works great from the command button on the Main Switchboard, but it still opens from the database window. Of course I will hide the database window on Startup, but doesn't it still go to it by holding down the shift key?


Thomas Bailey
tomcat@reportcop.com
 
Hi!

Take a look at this FAQ!

faq181-143

Be carefull doing this because you will be locking down your Db pretty tight. Especially if you make an MDE out of it.

hth


Jeff Bridgham
bridgham@purdue.edu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top