# Thread: Count/total number of records for userid

1. ## Count/total number of records for userid

I found a similar post to this but I hope to place the calculated equation in my field rules table.

My Table (users)

Userid _____Count___Total
Flyboy --------1-------3
Sarass --------1-------4
Flyboy -------1-------3
Flyboy -------1-------3
Sarass -------1-------4
Sarass -------1-------4
Grower --------1-------2
Grower -------1--------2
Sarass --------1-------4

My count field has the calculated IF(USERID>"1",1,0). This works fine.
My total field is where I’m in a quandary.
I hope to look at the userid and for each occurrence of the userid, add 1 from the Count field.
Number of times the userid is currently in the table

Flyboy = 3
Sarass = 4
Grower = 2

2. ## Re: Count/total number of records for userid

Employers post their jobs on the “posts” table
Employers registration information in the “users” table

I want to set a limit (5) on the number of jobs the employer can have posted at any given time.

In the users table, I have a field called “post_limits” currently set to numeric. When the employer registers, the employer starts out with the number 5 in this field.

In the posts table, I have a field called, “ad_count” currently set to numeric with a 1 in the field for the ad.

I would like to be able to subtract a 1 from the post_limits field each time the employer adds a job AND to be able to stop the employer from posting any jobs if the post_limits is 0.

Spent today researching this but could not find any viable solutions.

3. ## Re: Count/total number of records for userid

Eric,

I have a membership application, and we have been providing job postings for about 6 months from employers that may interest our members. Here's what we do:

We have a logical field in the job table named "active", and in order for any job to display, it has to be true.

So, as employers enter their jobs (we use an on line html editor so they enter them themselves) we send an automatic email to the placement chair. He reviews the job and checks the "active" checkbox if it is appropriate, follows up on missing information, and deletes the "genuine Rolex" watch ads.

Active jobs appear in the job listing until the expiration date. We set that initially to 30 days, but allow the employer to extend it if necessary. Any change triggers another email.

We get a count of the total number of jobs and total active jobs for each employer by using dbcount() and display that on the welcome screen as they log in.

By the way, we also use a character prefix on the id code for the employers of "E" and for applicants of "A". That way it is a simple matter after login to check the first character of ulink and route them to the proper pages.

Good luck,

Pat

4. ## Re: Count/total number of records for userid

Pat
Thank you for your response. Many jobs are posted daily and so I want to have this process automatic without any intervention from me.

I'm looking at the posting method and calculated field rules. Also looking at the events area of a grid.

In the desktop, I probably would be using the lookup() method in calculated fields somehow. Posting in desktop field rules does not work, correct?

Thanks

5. ## Re: Count/total number of records for userid

Eric,

I think Pat was trying to give you the hint of using the dbcount() function. That will very quickly give you the number of items in a table based on your specs so that it then just a matter of a simple "if" statement to redirect if more than 5.

http://support.alphasoftware.com/alp.../DBCOUNT().htm

6. ## Re: Count/total number of records for userid

Thanks Doug and Pat
I will look at dbcount(). Where would I put this if used?

In the grid? Where in the grid?
Field rules on desktop level?

Thanks

7. ## Re: Count/total number of records for userid

I also want the flexibility of allowing a particular client to post more jobs than others when I wish. (Change the posting limits for individual clients). So I'm thinking this count or total would have to be stored in a field and modified (Posted?) from the grid.

Just stuck on this.

8. ## Re: Count/total number of records for userid

Eric

I would put the dbcount() in a page between the login and the entry/edit grid. That way, if they have reached their limit, I could redirect them to a page to pay an additional fee to post more jobs or give them the option to delete (inactivate) some jobs that have been filled to make room for additional jobs. I would also have dbcount in a "thank you for posting" page which they would go to after each post. If they have three jobs to post and have already posted 4, then you need to check the count after each entry.

I would put the job limit in the employer record and look it up in the page after login where you gather all the other employer information from their record. That limit would only have to change if they pay for more jobs (or you give them more) or if their check bounces.

Pat

9. ## Re: Count/total number of records for userid

I was beginning to place code in the beforeinsertrecord event area of the post jobs grid. Where it would check the number balance in the Ads_allowed field in the users database and if the Ads_allowed is still in the positive, user is allowed to post another jobs and at the same time, subtract 1 from the Ads_allowed field.

If ads_allowed is 0, then the Result.cancel = .t.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•