Results 1 to 7 of 7
  1. #1
    azhar2006's Avatar
    azhar2006 is offline Expert
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2012
    Posts
    528

    Function NewSample

    Hello June7
    There are lines of codes you


    Is it possible for example in DB
    Code:
    Public Function NewSample() As String
    Dim strLabNum As String
    'search for aborted lab number and use that record, else if none then create new record
    strLabNum = Nz(DLookup("LabNum", "Submit", "IsNull(DateEnter)"), "")
    If strLabNum <> "" Then
        CurrentDb.Execute "UPDATE Submit SET DateEnter=#" & Date & "# WHERE LabNum='" & strLabNum & "'"
    Else
        strLabNum = Nz(DMax("LabNum", "Submit"), "")
        If strLabNum = "" Then
            'this accommodates very first generated number of blank database
            strLabNum = Year(Date) & "A-0001"
        Else
            'this accommodates change in year
            If Left(strLabNum, 4) = CStr(Year(Date)) Then
                strLabNum = Left(strLabNum, 6) & Format(Right(strLabNum, 4) + 1, "0000")
            Else
                strLabNum = Year(Date) & "A-0001"
            End If
        End If
        CurrentDb.Execute "INSERT INTO Submit(LabNum, DateEnter, EnterWho) VALUES('" & strLabNum & "', #" & Date & "#, '" & Form_Menu.cbxUser & "')"
    End If
    Form_SampleManagement.ctrSampleList.Requery
    NewSample = strLabNum
    End Function

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Download db that code is in from https://app.box.com/shared/r8nea07sng

    It is split design. Hold down shift key while opening frontend.
    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.

  3. #3
    azhar2006's Avatar
    azhar2006 is offline Expert
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2012
    Posts
    528
    Thank you very much
    But what is the name of the function did not see it

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    It is in the Misc module. The function name might be different in that uploaded version. Maybe GetNewLabNumber. I will have to check later.
    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.

  5. #5
    azhar2006's Avatar
    azhar2006 is offline Expert
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2012
    Posts
    528
    I have not found Thank you very much June
    Is it possible to create something simple from one table

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    I just confirmed in my current version that the function is named NewSample and it is in the Misc module. I am not going to build another db to demonstrate what is already available in provided db. Take the code sample and adapt to your requirements. When you encounter specific issue, post question.
    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.

  7. #7
    azhar2006's Avatar
    azhar2006 is offline Expert
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2012
    Posts
    528
    Well, and I will work on it Thank you June

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

Similar Threads

  1. Replies: 8
    Last Post: 01-31-2014, 01:45 PM
  2. HELP with IIF function
    By lpfluger in forum Queries
    Replies: 3
    Last Post: 04-01-2011, 12:01 AM
  3. Help with AVG function
    By techexpressinc in forum Reports
    Replies: 1
    Last Post: 03-23-2010, 07:47 AM
  4. Function Help
    By th3spankst3r in forum Programming
    Replies: 12
    Last Post: 03-22-2010, 12:41 PM
  5. Want function to get current function name
    By Davis DeBard in forum Programming
    Replies: 2
    Last Post: 08-13-2009, 05:02 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