Page 2 of 2 FirstFirst 12
Results 16 to 30 of 30
  1. #16
    bassplayer79 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2013
    Posts
    18

    washerapp.zip
    OK heres the DB. You might get some error messages since you wont be connected to SQL server. The washer number generator will work since its bound to a local DB. Thanks for your help!!!

  2. #17
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Great! After C&R and ZIP then go to Advanced posting and scroll down to Manage attachments.

  3. #18
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    It looks to me like you get the error after you add a WA to the WAS field and then press the button again. I think it is coming from the DMax() line. Still looking.

  4. #19
    bassplayer79 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2013
    Posts
    18
    Quote Originally Posted by RuralGuy View Post
    It looks to me like you get the error after you add a WA to the WAS field and then press the button again. I think it is coming from the DMax() line. Still looking.
    I think your right on. When I debug my code, I get the error on the dmax line.

  5. #20
    bassplayer79 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2013
    Posts
    18
    Also I noteiced my spelling mistake. Any way you could adjust my thread title and remove the "es" of Addes?

  6. #21
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Will the characters added to the WAS *always* be just 2 characters and will they always be "WA"?

  7. #22
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Quote Originally Posted by bassplayer79 View Post
    Also I noteiced my spelling mistake. Any way you could adjust my thread title and remove the "es" of Addes?
    Taken care of!

  8. #23
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Any answer to my post #21?

  9. #24
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    If [WAS] is an alpha-numeric, can't just add 1 to increment, have to parse the text part out. Here is how I generate unique alphanumeric ID:
    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
    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.

  10. #25
    bassplayer79 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2013
    Posts
    18
    Quote Originally Posted by RuralGuy View Post
    Will the characters added to the WAS *always* be just 2 characters and will they always be "WA"?
    Yes the characters will always be "WA", and no deviation from that.

  11. #26
    bassplayer79 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2013
    Posts
    18
    Quote Originally Posted by RuralGuy View Post
    Taken care of!
    Thank you very much!!

  12. #27
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    You could if you wanted, just prepend the "WA" every time it is displayed and not modify the table at all. Just a thought.

  13. #28
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Probably a better solution is to add a new field for the "WA" and put the two fields together when displaying them. That will give you the flexibility to have something other then "WA" in the future.

  14. #29
    bassplayer79 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2013
    Posts
    18
    Ok so heres what I did. I took it a slightly different direction then I initially thought I would. I created it as a function, did I need to? No but hey lifes to short. I created a new table that dumps the numerical numbers. I then call that function and add "WA", and dump that combination into a text box on my form, which is bound to a field in the table I use for tracking (Everything gets dumped into)

    Private Sub btnwasher_Click()
    'Call Generate_Number_Click

    wastxt = "WA" & Generate_Number_Click

    End Sub

    Public Function Generate_Number_Click() As Long
    On Error GoTo PROC_ERR
    Dim rst As ADODB.Recordset
    Dim strSQL As String
    Dim strNextID As Long


    '*** Find highest Serial No in the A0001_Serial_Num table and add 1 *******
    strNextID = DMax("[washer_serial_num]", "washer_ser_num") + 1
    '*** UPDATE SERIAL NO TABLE
    Set rst = New ADODB.Recordset


    strSQL = "SELECT washer_serial_num " & _
    "FROM [washer_ser_num]"
    rst.Open strSQL, CurrentProject.Connection, adOpenDynamic, adLockOptimistic, adCmdText


    With rst
    .AddNew
    ![washer_serial_num] = strNextID
    .update
    .Close
    End With

    Set rst = Nothing


    '*** Assign function the value of the Next # ******
    Generate_Number_Click = strNextID

    'Exit function now after successful incrementing or after error message
    End Function

  15. #30
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    It is of course your db but having a table full of just serial numbers does not make a lot of sense to me unless each record also contains useful fields that contain unique information about each unit.

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

Similar Threads

  1. mix of letters and numbers on the form
    By iscinar in forum Forms
    Replies: 15
    Last Post: 10-20-2013, 06:11 AM
  2. Sorting by Letters and then numbers with dashes
    By Analogkid in forum Queries
    Replies: 8
    Last Post: 04-29-2013, 05:05 PM
  3. IIF with numbers and letters
    By hzrdc2 in forum Queries
    Replies: 2
    Last Post: 03-28-2013, 07:29 AM
  4. Import Errors - Fields with Numbers and Letters
    By Eekers in forum Import/Export Data
    Replies: 5
    Last Post: 01-10-2012, 02:52 PM
  5. Removing all letters or all numbers from string
    By Hayley_sql in forum Programming
    Replies: 2
    Last Post: 09-16-2009, 02:01 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