autonumbering

G

Guest

i am writting a access programme, in which i have a tabel name"marketers"and
one form based on it.
one of the filed in tabel i need is id, and one control on the form is
based on this column,i need this control to generate numbers automatically(
i know i could use autonumbering filed, but it does generate number for each
new record and i have more than one id for one reocrd) but only when some
condition on the form met.( to put it simple, if the data is already in the
databse i dont want this control to generate the autonumber).on the contarary
if the data is not in the database i want this filed to generate autonumbers
in sequence.(i am hoping to achive this by one control(named: visittype) on
the form and write a code like: if visittype="first visit" then
.........generate the number; other wise execute a queary and find a match
from the databse for that record based on the first and last name.
i am trying to find answer to this from last one month.

thank you in advance for your reply and time.
 
G

Guest

This question only gets answered once or twice a week. Here is how to do that:

Dim lngNextNum as Long

If Me.txtVisitType = "First Visit" Then
lngNextNUm = Nz(DMax("[IDNumber]", "MyTable", "[FirstName] = '" _
& Me.txtFirstName & "' And [LastName] = '" & Me.txtLastName _
& "'"),0) +1
Else
lngNextNum = 1
End If
 

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