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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update Inventory Question

Status
Not open for further replies.

tdejournett

IS-IT--Management
Jul 4, 2002
6
US
I am writing a program for a very small video rental store. Having 1 big problem. Trying to track how many videos a customer rents. And after renting 10 movies I want to display a field on my form that shows customer is due 1 free rental. After customer rents "Free" movie to have the field go back to display "0" until they rent another movie at which time it shows "1" rental.

Any suggestions on where to find help?

TIA
Terry
 
Terry,

Use DCount to find the number of rentals.

Then use Mod like this....

intRentalsMade = DCount([Field],"Table",[CustomerID] = & YourCustomerID) Mod 11

Now if intRentalsMade is 0, then this one is free.....

Mod returns the remainder of a division so it's just what you need....

Craig

 
Hi Craig,

You have a good idea...just wanted to add one thing that Terry might need.

If customers can carry over free rentals, he will have to store the number of free rentals earned in a table. If this is the case, I'd suggest relating the customer table to tblFreeRental, or whatever he wants to call it. tblFreeRental would contain two fields: the CustomerID and the number of free rentals earned.

If the expression that you suggested returns 0, he would add 1 to the number of free rentals the customer has earned. He could then display the contents of that field on the form where it shows the number of free rentals a customer has earned. If customers can't carryover the number of free rentals, he could enclose your suggestion in an IIf statement similar to below.

Dim intFreeRental as Integer
Dim intRentalsMade as Integer

intRentalsMade = (DCount([Field],"Table",[CustomerID] = & YourCustomerID) Mod 11

intFreeRental = IIf(intRentalsMade = 0, 1, 0)

He would then display intFreeRental on the form. This method assumes that the customer must use their free rental after each 10th rental. If they don't, they lose it.

Have a great 4th of July everyone, and be safe!

God Bless America!

Best,

dz
 
And one change to yours.....

Dim intFreeRental as Integer
Dim blnRentalsMade as Boolean

intRentalsMade = (DCount([Field],"Table",[CustomerID] = & YourCustomerID) Mod 11

blnFreeRental = IIf(intRentalsMade = 0, True, False)

Craig

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top