Results 1 to 9 of 9
  1. #1
    nishant.dhruve is offline Advanced Beginner
    Windows 7 64bit Access 2013 64bit
    Join Date
    Aug 2016
    Posts
    34

    Data Entry even when it 0 .

    I have created a data entry form as shown below.
    So in this form all the fields get locked one data is eneterd and after that no one can delete it.
    But i have one problem here which is when i m trying to create a new data entry since the files SOPID is number, 0 is the default value that shows up into form for the new entry. So that lock that field on the form and isnt allowing to enter new data into field.
    What should i do, if there a 0 dataenter can be allowed if other than zero then it should be lock.
    I have use before update event code, and code is mention below. Please help me what are the changes are i require to do from the code below to allow dataentry even if its 0 in SOPID field.
    [code]
    Private Sub Form_Current()
    Empid.Locked = Not IsNull(Empid)
    sid.Locked = Not IsNull(sid)
    sdot.Locked = Not IsNull(sdot)
    Note.Locked = Not IsNull(Note)
    eid.Locked = Not IsNull(eid)
    edot.Locked = Not IsNull(edot)
    cle.Locked = Not IsNull(cle)



    End Sub


    [/Click image for larger version. 

Name:	dataentry.JPG 
Views:	15 
Size:	100.6 KB 
ID:	28127code]

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2013
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    Why not just remove the Default Value setting of 0
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    nishant.dhruve is offline Advanced Beginner
    Windows 7 64bit Access 2013 64bit
    Join Date
    Aug 2016
    Posts
    34
    Quote Originally Posted by Bob Fitz View Post
    Why not just remove the Default Value setting of 0
    i did but still i remains same

  4. #4
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,511
    Maybe try > 0?

  5. #5
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2013
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    May need to remove it at table level and at the form level

  6. #6
    nishant.dhruve is offline Advanced Beginner
    Windows 7 64bit Access 2013 64bit
    Join Date
    Aug 2016
    Posts
    34
    Quote Originally Posted by Bulzie View Post
    Maybe try > 0?
    where in VBA, if yes the how how shoud i write for this line.

    sid.Locked = Not IsNull(sid)

  7. #7
    nishant.dhruve is offline Advanced Beginner
    Windows 7 64bit Access 2013 64bit
    Join Date
    Aug 2016
    Posts
    34
    Quote Originally Posted by Bob Fitz View Post
    May need to remove it at table level and at the form level
    I tries to removed at both level still it remains same

  8. #8
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,741
    Just don't lock sid. You can't change it anyway if it's the primary key.

  9. #9
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,511
    If me.sid > 0 then
    me.sid.locked = True
    Else
    me.sid.locked = False
    End If

    Did a small test and this seemed to work. If sid is that field that has the default of 0.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 9
    Last Post: 03-01-2017, 10:00 AM
  2. Replies: 4
    Last Post: 12-21-2015, 10:57 PM
  3. Replies: 7
    Last Post: 03-05-2015, 07:34 AM
  4. Replies: 5
    Last Post: 03-09-2014, 07:16 PM
  5. how to copy last entry data for new entry
    By alexandervj in forum Access
    Replies: 7
    Last Post: 11-13-2013, 02:57 PM

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