Next number on continuous forms

G

Guest

I am using a continuous form to enter preliminary data. I am having a
problem with the numbering, though. Because I populated the table with
existing data, I instead of autonumbering, I used:
=DMax("QNumber","Table1")+1
What is happening is that when I enter data in the first field, the second
form pops into view, (normal, I know,) but the second "QNumber" is the same
as the first. I cannot figure out how to get it to save the QNumber to the
table before the second form opens so it can +1 it. I based the form on a
query so I could requery it, but it did not work either. Seems to be a
matter of timing. Any ideas? Thanks in advance!
 
A

Anonymous

Do you want the first QNumber to be saved in the table before the 2nd form
opens and tries to +1 it?

Try saving the 1st form's record in the first form's AfterInsert event,
perhaps. That way, when the 2nd form opens, the first form's QNumber is
saved in the table, and the 2nd form can +1 it.

Follow? :)
 
D

Douglas J Steele

The AfterInsert event firing would mean that the record has already been
inserted. There would be no need to do anything to be able to include the
QNumber from that record.
 
A

Anonymous

Yeah, you're right. Point was though that he should save the record before
the 2nd form opens. That's what I was trying to get across.

Thanks for pointing out my error.
 
B

BruceM

I should point out that Roger's example uses DMax in the Default Value for
the field, but I cannot find a way to make that work with a continuous form,
so I am suggesting a VBA approach.
A point on terminology is that what pops into view is the next record on the
continuous form, not a second form. It may help in future questions if such
distinctions are clear.

BruceM said:
One way using VBA is outlined here:
http://www.rogersaccesslibrary.com/download3.asp?SampleName=AutonumberProblem.mdb

Watch for line wrapping in the address. Note the method in Roger's
example for using the numbering system in a multi-user environment.

You could use the form's Current event, observing precautions in a
multi-user environment. It goes something like this:

If Me.NewRecord Then
Me.QNumber = DMax("[QNumber]","Table1") + 1
End If

Bryan said:
I am using a continuous form to enter preliminary data. I am having a
problem with the numbering, though. Because I populated the table with
existing data, I instead of autonumbering, I used:
=DMax("QNumber","Table1")+1
What is happening is that when I enter data in the first field, the
second
form pops into view, (normal, I know,) but the second "QNumber" is the
same
as the first. I cannot figure out how to get it to save the QNumber to
the
table before the second form opens so it can +1 it. I based the form on
a
query so I could requery it, but it did not work either. Seems to be a
matter of timing. Any ideas? Thanks in advance!
 
G

Guest

Thanks Bruce! I had used the link originally to set up the autonumber, but
it did not deal with continuous forms. Your little snippet of code worked
admirably! Thanks again.

BruceM said:
One way using VBA is outlined here:
http://www.rogersaccesslibrary.com/download3.asp?SampleName=AutonumberProblem.mdb

Watch for line wrapping in the address. Note the method in Roger's example
for using the numbering system in a multi-user environment.

You could use the form's Current event, observing precautions in a
multi-user environment. It goes something like this:

If Me.NewRecord Then
Me.QNumber = DMax("[QNumber]","Table1") + 1
End If

Bryan said:
I am using a continuous form to enter preliminary data. I am having a
problem with the numbering, though. Because I populated the table with
existing data, I instead of autonumbering, I used:
=DMax("QNumber","Table1")+1
What is happening is that when I enter data in the first field, the second
form pops into view, (normal, I know,) but the second "QNumber" is the
same
as the first. I cannot figure out how to get it to save the QNumber to
the
table before the second form opens so it can +1 it. I based the form on a
query so I could requery it, but it did not work either. Seems to be a
matter of timing. Any ideas? Thanks in advance!
 
B

BruceM

You're welcome. Always glad to pass along what I've learned here.

Bryan said:
Thanks Bruce! I had used the link originally to set up the autonumber,
but
it did not deal with continuous forms. Your little snippet of code worked
admirably! Thanks again.

BruceM said:
One way using VBA is outlined here:
http://www.rogersaccesslibrary.com/download3.asp?SampleName=AutonumberProblem.mdb

Watch for line wrapping in the address. Note the method in Roger's
example
for using the numbering system in a multi-user environment.

You could use the form's Current event, observing precautions in a
multi-user environment. It goes something like this:

If Me.NewRecord Then
Me.QNumber = DMax("[QNumber]","Table1") + 1
End If

Bryan said:
I am using a continuous form to enter preliminary data. I am having a
problem with the numbering, though. Because I populated the table with
existing data, I instead of autonumbering, I used:
=DMax("QNumber","Table1")+1
What is happening is that when I enter data in the first field, the
second
form pops into view, (normal, I know,) but the second "QNumber" is the
same
as the first. I cannot figure out how to get it to save the QNumber to
the
table before the second form opens so it can +1 it. I based the form
on a
query so I could requery it, but it did not work either. Seems to be a
matter of timing. Any ideas? Thanks in advance!
 

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