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!

JAZZZ - Limit Number of Records?

Status
Not open for further replies.

tomcat21

Programmer
Jul 28, 2002
69
US
What you want to do is add the dlookup code to whatever form you have opening and then include a message that your trial period has expired. I have code that does all this if you need it let me know and I will post it all.

JAZZ: Would you please post your code for this?

I am trying to use the below code to limit the number of record entries to 50 records.

if dlookup("numberofuses","tblUses") >50 then
docmd.quit
end if


How do I create the Table? What Data Type, etc. I keep getting an error on "nunmberofuses". What am I doing wrong?




Thomas Bailey
tomcat@reportcop.com
 
Use DCount instead of DLookup

IF DCount("[YourField]", "YourTableorQuery", "[OtherField] = " & WhereCondition) > 50 Then
...
End If

You have to fill in the blanks with your variable names

 
I added a field inside my Table named uses;
I added my Table name.
What is the Other Field?
Also, I am attempting to place the code in the On Click event of my command button on the switchboard. Is this right?


Thomas Bailey
tomcat@reportcop.com
 
With DCount, DMax, DLookUp, etc follow a similar format...

[tt]
IF DCount("[YourField]", "YourTableorQuery", "[OtherField] = " & WhereCondition) > 50 Then
[/tt]

YourField - the field you want to count. The name is less important for a aggregate function such as count, but is important if using DLookUp.

YourTableorQuery - Is either the table or a query that is being used.

"[OtherField] = " & WhereCondition - basically the WHERE clause used in an SQL statement. It is optional for the DCount function.

Code:
if [b]DCount[/b]("numberofuses","tblUses") >50 then
 docmd.quit
end if

As where you want to place your code - I do not know your application so it hard for me to tell - persumably wherever you want to "quit".


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top