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

need help with counter for a subset of data from 1 table

Status
Not open for further replies.

trayb

Programmer
Sep 30, 2002
25
US
How can I create a counter for a subset of records within the same table and increment it each time a record is added to the subset?

For example, say that I have a RealEstate table which includes single properties as well as porfolio properties. To distinguish the portfolio properties, there are 2 additional fields: PortName and PortID.

All property records (either type) will have a unique autonumber ID, but what I'm trying to do is create a unique number - PortID - that identifies the portfolio the property belongs to and its sequential number within the portfolio, starting back at zero for each portfolio subset entered.

To complicate things the portfolio properties will be entered via a popup form, activated by a button on the mainform, and the mainform is really a subform of a tab control. (whew..[3eyes]). In pseudocode, the click event would look something like:

btnAddPortProps_click
initialize count @ 0
increment count to 1
ppropID = [UniqueParentFormData] + count ????
display ppropID in form plus save w/ record
increment count

The counter itself does not need to be global nor stored independently. I just need to temporarily generate a counter value that in conjunction with another form field creates a unique ID that can be saved to each record, and then starts back at zero each time a portfolio is entered.

Can anyone help me figure out how to do this without having to create a separate counter table? Thanks!
 
Ok, since nobody answered I scrounged around the forums all day and finally found something helpful. In case anyone else has this problem, see thread705-389406. I modified Doug's code and created a function that accomplished what I was trying to do. Hope this helps somebody else in the future!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top