autonum

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How do you set conditional auto numbering?

I want to set a value (txt_run) with an autonum for each occurance of the another value (txt_county). For example: In the first record, the field txt_county is "Sac" I want txt_run to be "1". In the second record, txt_county is again "Sac" so i want txt_run to be "2". In the third record, txt_county is "Placer" so I want the txt_run field to be "1" because it is the first instance of "Placer". In the fourth record, txt_county is "Sac" so want txt_run to be "3". Is there a way I can code the form to do that for me?
 
Auto numbering doesn't work that way. It can be done, but you need to create the functionality. You'll need to create a table for reference and increment your counters via code. A class module would be ideally suited for this.
 
try something like

Private Sub txt_county_AfterUpdate()

Me!txt_run = Nz(DMax("RunFieldName", "MyTableName", _
"CountyFieldName = '" & Me!txt_county & "'"), 0) + 1

End Sub

hth


marie said:
How do you set conditional auto numbering?

I want to set a value (txt_run) with an autonum for each occurance of the
another value (txt_county). For example: In the first record, the field
txt_county is "Sac" I want txt_run to be "1". In the second record,
txt_county is again "Sac" so i want txt_run to be "2". In the third record,
txt_county is "Placer" so I want the txt_run field to be "1" because it is
the first instance of "Placer". In the fourth record, txt_county is "Sac"
so want txt_run to be "3". Is there a way I can code the form to do that
for me?
 
Back
Top