Gina,
I worked with the code behind a button to guarantee it fired.
Once I got it to work I moved it to the Before Update.
Now it works but it does not show up until after the record saves. That is OK. I took the auto save out of the code because it was causing an error. For now it works good enough. I will keep trying to get the auto save to work as well.
Thanks for all your help.
Bill
From: MS_Access_Professionals@yahoogroups.com [mailto:MS_Access_Professionals@yahoogroups.com]
Sent: Sunday, December 13, 2015 6:23 PM
To: MS_Access_Professionals@yahoogroups.com
Subject: RE: [MS_AccessPros] Re: Auto Invoice Number
Did you copy/paste? If yes, then retype the quotations marks.
Gina Whipp
Microsoft MVP (Access)
<http://www.access-diva.com/> access-diva
Specializing in Microsoft© Access® Solutions
From: MS_Access_Professionals@yahoogroups.com [mailto:MS_Access_Professionals@yahoogroups.com]
Sent: Sunday, December 13, 2015 6:59 PM
To: MS_Access_Professionals@yahoogroups.com
Subject: RE: [MS_AccessPros] Re: Auto Invoice Number
Gina,
I have read over the page you referenced. I thought I understood it but I am getting an error.
Just like the instructions said, In the From property Before Update I put this code.
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.NewRecord Then
Me.IncNumber = Nz(DMax("IncNumber", "t_Invoices"), 0) + 1
End If
End Sub
It will not fire. The field on the form stays blank. Me.IncNumber is referring to the field on the form that holds the Invoice Number.
When I changed the code to more closely represent what was on the web site, see below
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.NewRecord Then
Nz(DMax("IncNumber", "t_Invoices"), 0) + 1
End If
End Sub
I get an error message, the line turns red and the curser hovers over the "+".
The error messages says Compile Error: Expected =
Which is why I tried the top example.
Any help you, or anyone, could provide would be greatly appreciated.
Thanks,
Bill
MN
With rain in December, which is Awsome.
From: MS_Access_Professionals@yahoogroups.com [mailto:MS_Access_Professionals@yahoogroups.com]
Sent: Saturday, December 12, 2015 7:00 PM
To: MS_Access_Professionals@yahoogroups.com
Subject: [MS_AccessPros] Re: Auto Invoice Number
Use DMax(), have a look at...
http://regina-whipp.com/blog/?p=704
[Non-text portions of this message have been removed]
Posted by: "Bill Singer" <Bill.Singer@at-group.net>
| Reply via web post | • | Reply to sender | • | Reply to group | • | Start a New Topic | • | Messages in this topic (6) |
Tidak ada komentar:
Posting Komentar