Automated Mail Delivery Time Using Table Data

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • elak6
    New Member
    • Nov 2011
    • 21

    #16
    Hi Neopa,
    Thanks for all your help
    I ran the code posted above but i seem to be encountering a problem
    Everytime i close the form and then reload it, it never saves the value of the next update text box
    Please can you help

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32633

      #17
      I don't understand why that would be the case if you used the code I suggested. Can you post the code you're using for me to look at.

      Comment

      • elak6
        New Member
        • Nov 2011
        • 21

        #18
        Hi Neopa,
        Happy New Year to you and hope you had a good holiday
        I ran the code exactly as you put it and it is still giving me errors. The code i ran is shown below:-

        Code:
        Private Sub Form_Open(Cancel As Integer)
            With Me
                If Date = .txtSendDate Then     ' Now option
                If Date <> .txtSendDate Then      ' Deferred option
                RetValue = MsgBox("NextUpdate is in the future/past", vbInformation)
                    Cancel = True
                    Exit Sub
                End If
                End If
                .OnTimer = "[Event Procedure]"
                .TimerInterval = 50
            End With
        End Sub

        Code:
        Private Sub Form_Timer()
            Dim lngTI As Long
          
            With Me
                lngTI = .TimerInterval
                .TimerInterval = 0
                .OnTimer = ""
                '.txtSendDate = DateAdd("d", 30, CDate(.txtSendDate))
                .txtSendDate = DateAdd("d", 30, (.txtSendDate))
                ' Call RunCommand(acCmdSaveRecord) doesn't work here
                .Dirty = False    ' Has the same effect as line above and saves record
                Call coke
                .TimerInterval = lngTI
                .OnTimer = "[Event Procedure]"
            End With
        End Sub
        Errors Encountered
        When the code is ran..the line
        .Dirty= False gives a debug error
        The error is Run-time error '2455'
        You have entered an expression that has an invalid reference to the property Dirty

        Also the txtSendDate value is updated but when i close the form and reopen it the txtSendDate value is blank..i.e. it is not saved once the form is closed

        At this point, i have tried a lot of ways but i am totally clueless as to what is going wrong.Please help and sorry for incovenience caused

        Thanks

        Comment

        • NeoPa
          Recognized Expert Moderator MVP
          • Oct 2006
          • 32633

          #19
          It seems you haven't copied the code across very well. It is critical, in such situations, to use Copy / Paste to avoid such mistranslations .

          If you look at lines #3 & #4 in your code and compare them to mine you'll see a big difference (in effect rather than characters). Line #4 should also be <= rather than <>. Your code, as it stands, ensures the code can never be executed. This also explains the extra line #9 that you have (which is incorrect).

          As for the .Dirty problem, I admit that confuses me. It's been a few weeks since I looked at this so I'm not even sure I kept the earlier work (I probably did, but finding it is another matter). I'm pretty sure I tested it at the time though and it worked. Otherwise the DoCmd.SaveRecor d() line would still be there (It was commented out). The txtSendDate value being updated is dependent on the .Dirty line working correctly, so no surprise there at this stage. I'm working in Access 2003. Which version are you working with?

          I notice that you have changed my line :
          Code:
          .txtSendDate = DateAdd("d", 30, CDate(.txtSendDate))
          to :
          Code:
          .txtSendDate = DateAdd("d", 30, (.txtSendDate))
          Essentially removing the call to CDate(). This shouldn't have too much of an effect in itself, but the fact you made the change indicates something amiss with the data entered (I'm assuming the change wasn't a random idea).

          PS. Tip: Always compile your code before testing it. It helps avoid wasting your time and energy.

          Comment

          • elak6
            New Member
            • Nov 2011
            • 21

            #20
            Hi Neopa,

            Yeah i just saw the chnages you highlighted, was testing and tweaking the code and didnt even realise the changes i made.
            Currently, i am using Access 2007
            I have corrected the code and ran it again but is still giving me the error about the Dirty property
            I guess i need to go back to the the foundation/beginning and figure out how i went wrong

            Thanks for all your help,
            Really appreciate it

            Comment

            • NeoPa
              Recognized Expert Moderator MVP
              • Oct 2006
              • 32633

              #21
              As that's the only problem I would suggest checking the Context-Sensitive Help system for "SaveRecord". It may be that this will work in 2007. Alternatively, you may find there how best to save the active record in a form from there. That's the only piece of the puzzle that's missing ATM. Restarting from scratch seems to me to be throwing the baby out with the bath-water. An option, but not a good one.

              Comment

              Working...