-----Original Message-----
I am not sure I am following you. How do you store them? The line
Me![InvoiceNumber] = DMax("InvoiceNumber", "tblSeries") + 1
puts the incremented number into the table, I think, assuming that there
is a field named InvoiceNumber in the table bound to the form. Reference
Me![InvoiceNumber]
refers to the underlying data in the table. I guess in your case it is
called NextNumber, I thought you'd substitute the name. If your
pseudoAutoNumbe field is called NextNumber, make it look like this:
if Me.NewRecord then
Me![NextNumber] = DMax("NextNumber", "tblSeries") + 1
endif
What do you mean "sequencing as they should (kind of)"? It seems they
either do or don't?
Pavel
Eva said:
Pavel,
The new code is working great; the numbers are sequencing
as they should (kind of). Please forgive me for being
stupid, but how do I store the number value in the table
holding the main records? Sorry, I'm very new to the code.
Thanks for all your help!
-----Original Message-----
How about replacing the entire code in the original routine by this:
if Me.NewRecord then
Me![InvoiceNumber] = DMax
("InvoiceNumber", "tblSeries") +
1
endif
Some people will say that domain aggregate functions
are
slow but with
todays PCs I think above is as fast as anything else.
And
much less
code, much more readable.
I also don't think that XP alone is enough for runtime distribution.
Should be XP Developer edition. I run XP and develop
for
2000 simply by
working with DBs saved in 2000 format.
Pavel
Eva Shanley wrote:
Pavel, thanks for the response. I'd already discovered
the reference to DAO.Recordset and changed that code, but
I'm still having problems. Now I'm getting a "No current
record" error on the .MoveFirst line. I did check the
reference libraries and I have the Microsoft DAO 3.6
Object Library checked. Is that what I need? Also,
I
do
have Access 2002; I have XP installed so I can develop
runtime applications. I also have Access 2000 installed
because I'm developing this database in that version. Is
that goofing me up?
-----Original Message-----
You must have Access 2002.
Make sure you have DAO libraries chacked in your
References.
Change
Dim rst As Recordset
to
Dim rst As DAO.Recordset
and both issues should go away. And don't forget to put
the original
..Edit back in.
I also think that you can make invoice number in a
simpler way.
Cheers,
Pavel
Eva Shanley wrote:
I asked for help generating an invoice number
automatically, and did receive some code to use to
accomplish this. However, I'm getting 2 errors in this
code: 1) .EditMode = "Invalid use of property" (original
code specified .Edit, but that didn't work either)
2) Set rst = db.OpenRecordset etc. = "type
mismatch"
Can anyone help me with these problems? Thanks!
Sub Command52_Click()
Dim rst As Recordset
Dim db As database
Dim lngNextNumber As Long
Set db = CurrentDb
Set rst = db.OpenRecordset("tblSeries", , dbDenyRead)
With rst
.MoveFirst
.EditMode
lngNextNumber = ![NextNumber]
![NextNumber] = lngNextNumber + 1
.Update
End With
rst.Close
Set db = Nothing
End Sub
.
.
.