Click to See Complete Forum and Search --> : Creating a new invoice
jtracy
November 22nd, 1999, 10:11 AM
In my program I want to click a new invoice button that will clear all fields and in my invoice number field increase the number by one according to the highest invoice number in my database, but it won't. Any ideas? I really could use some help before tomorrow.
Thanks
Jessica Tracy
Allen Noakes
November 22nd, 1999, 10:32 AM
Jessica,
If you could provide more information about which grid you are using , as there are different types, what Database type you are using would be helpfull. I have had some of the same problems in the past and the answers are different for each one.
Email your replies and I will help.
Allen Noakes
VB Programmer/Analyst
Dames & Moore Group
misan@dames.com
jtracy
November 22nd, 1999, 10:57 AM
In this program I am just using textboxes and I want my textbox to increment 1 from the highest invoice number already in my database. I am using DAO also. It seems like it should be so simple, but yet I can't get it to work. I'd appreciate any help you could give me.
Thanks
Jessica
Allen Noakes
November 22nd, 1999, 01:58 PM
The answer is as follows.
Dim strSQL as string
strSQL = "SELECT TOP 1 InvoiceNbr FROM Invoice ORDER BY InvoiceNbr DESC;"
The "TOP 1" will return only one record which is all you need, "ORDER BY InvoiceNbr DESC" will get the largest invoice number in your database. This should work with either SQL Server or Access.
Allen Noakes
VB Programmer/Analyst
Dames & Moore Group
misan@dames.com
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.