Page 2 of 2 FirstFirst 12
Results 16 to 21 of 21
  1. #16
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    I'm Minty, Micron is a different forum member.

    You appear to have removed the default value I put in.
    As I explained previously, you don't need to use code to fill that out, just use the default value, it will always appear on a new record.


    =Nz(DMax("empno","main_data"),0)+1



    And remove the code in your before update event.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  2. #17
    deepaksharma is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Jul 2023
    Location
    india
    Posts
    389
    Quote Originally Posted by Minty View Post
    I'm Minty, Micron is a different forum member.

    You appear to have removed the default value I put in.
    As I explained previously, you don't need to use code to fill that out, just use the default value, it will always appear on a new record.


    =Nz(DMax("empno","main_data"),0)+1

    And remove the code in your before update event.
    ohh sorry minty for saying wrong name.
    Actually my program will be run by many users on sharing pc if any user closes the form without clicking on "Save and Shades" button then the series of empno will be missed so I want that till the time the user fills the form completely The empno is not generated until you click on the Save and Shades button.
    So I coded in the BeforeUpdate event. Can my problem be solved keeping this method in mind?
    Thank you.

  3. #18
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    The EmpNo value when set by the default value won't be saved until the record is saved.

    I would still use the default value but run a check on the forms before update, to ensure it's not duplicated, and if it is get a new value?
    Or simply use the Autonumber field as an Identifier and don't worry about it being sequential?
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  4. #19
    deepaksharma is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Jul 2023
    Location
    india
    Posts
    389
    Quote Originally Posted by Minty View Post
    The EmpNo value when set by the default value won't be saved until the record is saved.

    I would still use the default value but run a check on the forms before update, to ensure it's not duplicated, and if it is get a new value?
    Or simply use the Autonumber field as an Identifier and don't worry about it being sequential?
    You are right, by running this program on two PCs in the manner suggested by you, the error of duplicate value is coming. To avoid this, please tell the coding of the method you have given to check the autonumber field in the before update event.
    Please thanks in advance

  5. #20
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    A simple DCount should do it

    Code:
    IF Dcount("1", "main_data","EmpNo = " & Me.Empno) > 0 Then 
        Me.EmpNo   =Nz(DMax("empno","main_data"),0)+1
    End if
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  6. #21
    deepaksharma is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Jul 2023
    Location
    india
    Posts
    389
    Quote Originally Posted by Minty View Post
    A simple DCount should do it

    Code:
    IF Dcount("1", "main_data","EmpNo = " & Me.Empno) > 0 Then 
        Me.EmpNo   =Nz(DMax("empno","main_data"),0)+1
    End if
    ohh thank you thank you So much......

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 09-09-2017, 10:24 PM
  2. Data Confirmation Screen on Form
    By chaddresnick in forum Access
    Replies: 4
    Last Post: 03-29-2015, 10:11 AM
  3. Replies: 6
    Last Post: 11-24-2012, 06:50 PM
  4. Confirmation on what I am doing
    By newtoAccess in forum Access
    Replies: 5
    Last Post: 12-10-2010, 01:01 PM
  5. Replies: 3
    Last Post: 11-16-2010, 10:08 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums