Gina,
I did copy past and then change some things.
I retyped the " and I did see them change but the code will not do anything when I open the form to a new record. I am thinking is should fill in the field on the form as soon as the form is opened. For some reason it is not firing.
Below is the code I have .
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.NewRecord Then
Me.IncNumber = Nz(DMax("IncNumber", "t_Invoices"), 0) + 1
End If
End Sub
Maybe I will try to put the code in a button and hit the button and see what happens.
Any other thoughts?
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 (5) |
Tidak ada komentar:
Posting Komentar