Jumat, 10 Maret 2017

Re: [MS_AccessPros] Numeric field to increment value by 1 on next record

 

Khalid-


That looks good to me!

John Viescas, Author
Effective SQL
SQL Queries for Mere Mortals 
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications 
(Paris, France)




On Mar 10, 2017, at 5:07 PM, Khalid Tanweer khalidtanweerburrah@yahoo.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:



Hi John,

I have a form "New Cargo Collection Input" (it is been renamed on the request of user, previously it was "Collection Voucher" , i'm mentioning this because i had many questions regarding this form and you may recall my previous questions) on its subform "NewCargoCollectionInputsubform" there is a Numeric field "CartonNo".

My user's demand was that while doing data entry on the next row "CartonNo" should increment the value of previous records
"CartonNo" and if the sequence breaks he may be able to enter manually new "CartonNo" like:
1
2
3
25
26
and so on like this. I have put the following code on before update event on the subform:

Private Sub Form_BeforeUpdate(Cancel As Integer)
    If Me.NewRecord Then
        CartonNo.DefaultValue = Chr(34) & CartonNo + 1 & Chr(34)
    End If
End Sub

I have tested it, and it works fine. I just need to know for my personal knowledge and information is the event and code
correct. OR there is some other better and professional way to accomplish this task ?

Best regards,
Khalid



__._,_.___

Posted by: John Viescas <johnv@msn.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (2)

Have you tried the highest rated email app?
With 4.5 stars in iTunes, the Yahoo Mail app is the highest rated email app on the market. What are you waiting for? Now you can access all your inboxes (Gmail, Outlook, AOL and more) in one place. Never delete an email again with 1000GB of free cloud storage.


.

__,_._,___

Tidak ada komentar:

Posting Komentar