Counter field

C

Clay

Hello All:

Newbie question here....I really don't know the proper way to ask this
question or if it is even the correct way to try going about getting this
accomplished.

I have a table "Table1" with fields "counterID" and "projectnumber".

What I would like to do is for each project number I want the counterID
filed to increment.

Meaning if I insert 3333 into the projectnumber field then counterID field
would set to 1 then..

I do it again ..insert 3333 into the projectnumber field and the counterID
would increase to 2 then

this time I enter 4444 into the projectnumber field and the counterID filed
would set to 1 again...etc....etc...hopefully you get the idea...

right now I can increment the counterID field on the form using the
following code...

I just can't figure out how to count based on the value of the projectnumber
field.

Any help or direction would be greatly appreciated.

Thanks

Clay
 
A

Adrian Tofan

instead of:
Me!counterID = Nz(DMax("counterID", "Table1"), 0) + 1
Me.counterID.Requery

try this:
Me!counterID = Nz(DCount("[CounterID]", "Table1", "[projectnumber]=" &
me.projectnumber),0) +1

(i don't think you need: Me.counterID.Requery)
 
C

Clay

Thanks Adrian....that worked great....I took out the requery also...not
needed as you suggested...

I really appreciate your response....

Clay

Adrian Tofan said:
instead of:
Me!counterID = Nz(DMax("counterID", "Table1"), 0) + 1
Me.counterID.Requery

try this:
Me!counterID = Nz(DCount("[CounterID]", "Table1", "[projectnumber]=" &
me.projectnumber),0) +1

(i don't think you need: Me.counterID.Requery)

Clay said:
Hello All:

Newbie question here....I really don't know the proper way to ask this
question or if it is even the correct way to try going about getting this
accomplished.

I have a table "Table1" with fields "counterID" and "projectnumber".

What I would like to do is for each project number I want the counterID
filed to increment.

Meaning if I insert 3333 into the projectnumber field then counterID field
would set to 1 then..

I do it again ..insert 3333 into the projectnumber field and the counterID
would increase to 2 then

this time I enter 4444 into the projectnumber field and the counterID filed
would set to 1 again...etc....etc...hopefully you get the idea...

right now I can increment the counterID field on the form using the
following code...


I just can't figure out how to count based on the value of the projectnumber
field.

Any help or direction would be greatly appreciated.

Thanks

Clay
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top