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

    error message

    Hello, men
    When you call this function with an event the time
    Show me an error message


    Code:
    Private Sub Form_Timer()
    Call Backup("c:\Test\202.mdb", "c:\Test\ds\az.mdb")
    End Sub
    Code:
    Public Sub Backup(strSource As String, strTarget As String)
    'creates a copy of whatever file you want to whatever folder you want, overwrites if already there
    Dim fso As Object, fsoBackup As Object
    Dim tempDate As Variant
    Set fso = CreateObject("scripting.filesystemobject")  'set our filesystem object
    If fso.FileExists(strTarget) Then   'if target does exist
        Set fsoBackup = fso.getfile(strTarget)  'set target variable
        tempDate = DateAdd("d", 1, fsoBackup.DateCreated)   'add whatever length of time to check (daily, hourly, etc.)
        If Now() >= tempDate Then 'check if now is later than the date/time we want to copy it over next
            fso.deletefile strTarget 'delete target to reset datecreated property
            fso.copyfile strSource, strTarget 'copy source to target
        End If
    Else
        fso.copyfile strSource, strTarget  'if target doesn't exist, immediately create backup
    End If
    End Sub
    Click image for larger version. 

Name:	rrrr.JPG 
Views:	26 
Size:	21.8 KB 
ID:	17905

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    What's the error message?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    If I recall correctly, the Form_Timer event property is for adjusting the Form's Timer property and is not used as an Event Handler.

    If you want to call a function or procedure, perhaps the Form_Load event handler is more appropriate.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    You can have code in the timer event. Perhaps you're thinking of the timer interval property.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    I, most likely, am.

  6. #6
    azhar2006's Avatar
    azhar2006 is offline Expert
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2012
    Posts
    528
    Thank you Professors
    simple backup utility that I thought I would share.

  7. #7
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Are you still having problems with this?

  8. #8
    azhar2006's Avatar
    azhar2006 is offline Expert
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2012
    Posts
    528
    Yes I can not
    an example of the application

  9. #9
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Again, what is the error message?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  10. #10
    azhar2006's Avatar
    azhar2006 is offline Expert
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2012
    Posts
    528
    Thank you pbaldy for the follow-up Thread This is the message
    Click image for larger version. 

Name:	Capture.JPG 
Views:	20 
Size:	18.3 KB 
ID:	17911

  11. #11
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    If you named the module the same as the sub, you can't.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  12. #12
    azhar2006's Avatar
    azhar2006 is offline Expert
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2012
    Posts
    528
    Thank you pbaldy
    How, do you explain more

  13. #13
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    It sounds like you've named the module itself "Backup", rather than just the sub shown above. Look in the VBA editor on the left side and see what's listed under "Modules".
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  14. #14
    azhar2006's Avatar
    azhar2006 is offline Expert
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2012
    Posts
    528
    Yes This is the image module
    Click image for larger version. 

Name:	211.JPG 
Views:	14 
Size:	62.7 KB 
ID:	17918

  15. #15
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    I don't know how to say it any clearer. They (the module and the sub) CAN'T have the same name. Change the name of the module.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 3
    Last Post: 05-15-2014, 09:59 AM
  2. Replies: 15
    Last Post: 11-01-2013, 03:24 PM
  3. Replies: 7
    Last Post: 07-24-2013, 02:01 PM
  4. Error message 'Error in Loading DLL'
    By rahayes in forum Programming
    Replies: 2
    Last Post: 09-22-2012, 05:17 AM
  5. Replies: 2
    Last Post: 06-23-2012, 11:59 PM

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