Results 1 to 5 of 5

Thread: Code Problems

  1. #1
    Join Date
    Dec 2003
    Location
    Arizona
    Posts
    9

    Unanswered: Code Problems

    Can someone help me out:

    Here is the problem:

    I have a Maintenance Request form I use. On the form is a button to generate a Work Request Number. This number is in the format mmddyyXX, where XX is the actual work request number for that day. For example, today is 1/8/04. The first request for today would be 01080401, the next request today would be 01080402.

    Ok here is the problem, up until today the script worked fine. However starting with todays date, it won't generate a new number, i.e. the second request today stills comes up as 01080401. In the script is a command to verify no job exists that contains that number but it isnt working either. I do not get a warning about a job number containing that request number. I changed the system date to yesterday's date and the script works fine. I also changed it to a date in the future but it does not work correctly. It seems like today's date started the problem.

    Here is the script for the button:

    Private Sub Work_Request_Click()
    Dim Today As String, Last As String
    Dim Next_Request As STring, Next_Count As Integer
    If Not IsNull (Me.Work_Request_Number) Then
    Dim x As Integer
    x= MsgBox ("Please Note:@@" & "This record already contains a Work Request Number. Do you want to generate a new number for this record?", vbCritical + vbYesNo, "Warning....")
    If x = vbNo Then Exit Sub
    End If
    Today = Format (Now(), "mnmddyy")
    If DCount ("[Work_Request_Number]", "Work Requests") > 0 Then
    Last = Left (DLast("Work_Request_Number", "Work Requests"),6)
    Else
    Exit Sub
    End If
    IF Today = Last Then
    Next_Count = Int (Right (DLast("Work_Request_Number", Work Requests"), 2)) + 1
    Next_Request = Format (Now(), "mmddyy") & Right ("0" & Next_Count, 2)
    Else
    Next_Request = Format (Now(), "mmddyy") & "01"
    End If
    Me.Work_Request_Number = Next_Request

    End Sub


    Please Help ASAP

  2. #2
    Join Date
    Sep 2002
    Location
    South Wales
    Posts
    580

    Today = Format (Now(), "mnmddyy")

    mmddyy?
    Windows Server 2003-8 / Terminal Services / SQL 2000 / Access 2003 / Office 2003-7 / Exchange 2003-7 / Blackberry Enterprise Server / AutoCAD / Lambert And Butler / Red Bull

  3. #3
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    is the "n" in
    Today = Format (Now(), "mnmddyy")
    supposed to be there?

    izy
    currently using SS 2008R2

  4. #4
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    sorry Gareth!
    i type too slow
    izy
    currently using SS 2008R2

  5. #5
    Join Date
    Dec 2003
    Location
    Arizona
    Posts
    9

    No

    Its not there, its a typo, sorry,

    And actually figured the problem out. Its not a problem with the script itself. For some Access didn't save the record so on the next attempt to generate a number it did not recognize the previous entry. I did a manual save of the record and now everything works fine.

    Thanks anyway



    Originally posted by izyrider
    is the "n" in
    Today = Format (Now(), "mnmddyy")
    supposed to be there?

    izy

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •