Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Previous row + 1

Status
Not open for further replies.

mru

Technical User
May 26, 2002
20
GB
I have a data entry form for entering invoices, I have the 'autofillnewrecord' module working correctly on the form for the account name and date fields. Is it possible to use this module or what syntax would I need in order to take the invoice number from the previous line increase the number by one and enter it as a default value on the current line. I would like it, if possible, to be the default value because although the numbers usually are input in order that is not always the case.

Hope someone can help

Thanks
MRU
 
Let's assume that the name of the field on your form where the user enters the invoice number is txtInvoiceNo. I am not familiar with the 'autofillnewrecord' module. If it is a VB program, you might try adding the following line of code to that module before it moves the record pointer to the new record.

txtInvoiceNo = txtInvoiceNo.Value + 1

This assumes that the invoice is an integer. If it is a string, you would have to do something like this:

txtInvoiceNo = Str(Val(txtInvoiceNo.Value) + 1)

If you don't have any control over when it moves the record pointer to the new record, you could store the last invoice number entered into a hidden field on the form, and use the value of that field in the formula above.

If I misinterpreted your issue, please write back and I'll take another stab at it.

dz
 
Thanks dz for your reply, I got the autofillnewrecord to copy the previous lines number into the current line and then used the first code you suggested in the field before the invoicenumber field to increase the amount by one.
Thanks again
MRU
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top