Page 2 of 2 FirstFirst 12
Results 16 to 22 of 22
  1. #16
    JRodko is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Oct 2018
    Posts
    127
    I am still having (Auto) show up when I enter a new record. Would my error be somewhere else? Here is my code.

    Private Sub Form_BeforeInsert(Cancel As Integer)
    If Me.SAMP_Num = "(Auto)" Then
    Dim PrevValue As Variant


    PrevValue = ELookUp("SAMP_NUM", "[Geochemistry - Samples]", , "SAMP_NUM Desc")

    If Not IsNull(PrevValue) Then
    'Increment the value from last time
    Me.SAMP_Num = Succ(PrevValue)
    Else
    'No previous records were found so start from the bottom
    Me.SAMP_Num = "SRC000000"
    End If
    End If


    End Sub

  2. #17
    kd2017 is offline Well, I tried at least.
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    1,165
    Reattach your db please

  3. #18
    JRodko is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Oct 2018
    Posts
    127
    Here we go. I very much appreciate you taking the time to help me with this. I have been messing about for over an hour with no progress.
    Attached Files Attached Files

  4. #19
    kd2017 is offline Well, I tried at least.
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    1,165
    The database you posted works for me as is!
    Click image for larger version. 

Name:	Untitled.jpg 
Views:	14 
Size:	45.6 KB 
ID:	36874

    So it display's "auto" until a new record is actually created, then it will generate a samp_num. "auto" is just a place holder, it's supposed to say that, it indicates to the user that if left alone a number will be generated automatically. A place holder much in the same way the AutoNumber primary key field would say "(New)"...

  5. #20
    JRodko is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Oct 2018
    Posts
    127
    EDIT: OK. I figured it out! It's working for me now, but it won't fill until I start typing in the comment box.

    Is there a way to make it full automated, so that I can just keep tabbing through? The same thing happens with my Length field.

    Thank you so much!!!

    EDIT2: On second thought. I think this actually works better. Thank you again!

    I don't know know to mark this as solved but it's solved.

    Solved
    Solved.
    Solved!

  6. #21
    kd2017 is offline Well, I tried at least.
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    1,165
    I don't follow, it is fully automated. It'll fill as soon as you type in any of the fields or start a new record. Do you mean you need it to edit existing records?

    BTW it *might* be better for your situation locate the previous samp_num by latest modified date rather than highest samp_num. Like so:
    Code:
    PrevValue = ELookUp("SAMP_NUM", "[Geochemistry - Samples]", , "datModified Desc")

  7. #22
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    The sample number will not generate until you enter some value in another control. The only control that does not have a default value is Comment. As soon as something is typed in that box or any of the others to overwrite default value, the sample number is created. Unfortunately, because this is first record the number is SRC000000. My original code deals with this circumstance.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. default property values
    By Gili in forum Forms
    Replies: 3
    Last Post: 03-22-2017, 10:42 AM
  2. Default values in a form
    By Aleem in forum Access
    Replies: 5
    Last Post: 12-11-2013, 04:39 PM
  3. default values in a form
    By kmims44 in forum Forms
    Replies: 9
    Last Post: 06-28-2012, 12:35 PM
  4. Default Values In Form
    By ASW in forum Programming
    Replies: 2
    Last Post: 01-18-2012, 08:55 AM
  5. Default Values
    By twainscott in forum Programming
    Replies: 0
    Last Post: 09-14-2006, 11:18 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