Results 1 to 40 of 52

Thread: [RESOLVED] DB Backup and Restore

Hybrid View

  1. #1
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: DB Backup and Restore

    You can place the "Call PromptBackup" in the Activate event but then you will need to create a boolean flag variable to only let it call it once or when the user minimizes or switches apps, when they come back it will active again.

    Or you could use a timer that is set to enabled in the last line of the MDIForm_Load event and an interval of about 500 (30 seconds) to fire its Timer event procedure where you wil have the call to your "Call PromptBackup" call. Disable the timer as the first call as the next line of code should be the one calling the backup call..
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  2. #2

    Thread Starter
    PowerPoster Simply Me's Avatar
    Join Date
    Aug 2003
    Posts
    2,748

    Re: DB Backup and Restore

    Quote Originally Posted by RobDog888
    You can place the "Call PromptBackup" in the Activate event but then you will need to create a boolean flag variable to only let it call it once or when the user minimizes or switches apps, when they come back it will active again.

    Or you could use a timer that is set to enabled in the last line of the MDIForm_Load event and an interval of about 500 (30 seconds) to fire its Timer event procedure where you wil have the call to your "Call PromptBackup" call. Disable the timer as the first call as the next line of code should be the one calling the backup call..
    Got it working!

    One last Problem. What if the first day of the month falls on Saturday or Sunday (no work, computers are off) is it still possible that vb would check if DB was backed-up or not?
    To give is always to be NOBLE...
    To received is always to be BLESSED....
    Each day strive to be NOBLE
    Each day strive to be BLESSED

    If this post has helped you. Please take time to rate it.

    >=|+|=< Simply Me >=|+|=<

    ----------------------------------------
    Connection Strings | Number Only in Textbox | Splash Screen with Progress Bar | Printing to 1/2 of perforated bond paper |
    Freeze 2005 DataGridView Column

  3. #3
    PowerPoster
    Join Date
    May 2006
    Posts
    2,988

    Re: DB Backup and Restore

    Quote Originally Posted by Simply Me
    Got it working!

    One last Problem. What if the first day of the month falls on Saturday or Sunday (no work, computers are off) is it still possible that vb would check if DB was backed-up or not?
    VB Code:
    1. Dim Firstofmonth As Date
    2.     Dim Lastofmonth As Date
    3.     Dim DateBefore As Date
    4.     Dim DateBeforeThat As Date
    5.     Dim ThisDay As String
    6.     Dim YesterDay As String
    7.    
    8.     Firstofmonth = DateAdd("d", 1, Date - Day(Date))
    9.     Lastofmonth = DateAdd("m", 1, Date - Day(Date))
    10.     ThisDay = Format(Now, "dddd")
    11.     YesterDay = Format(Now - 1, "dddd")
    12.     DateBefore = DateAdd("d", -1, Date)
    13.     DateBeforeThat = DateAdd("d", -2, Date)
    14.    
    15.     Debug.Print Firstofmonth
    16.     Debug.Print Lastofmonth
    17.     Debug.Print DateBefore
    18.     Debug.Print DateBeforeThat
    19.     Debug.Print ThisDay
    20.     Debug.Print YesterDay
    21.    
    22.     If Date = Firstofmonth Then
    23.         Debug.Print "Today is first of Month"
    24.     End If
    25.    
    26.     If ThisDay <> "Saturday" And ThisDay <> "Sunday" Then
    27.         Debug.Print "Today is a Weekday"
    28.     End If
    29.    
    30.     If YesterDay = "Sunday" Then
    31.         Debug.Print "Today is a First Of Week"
    32.     End If
    33.    
    34.     If DateBefore = Firstofmonth And ThisDay = "Monday" Then
    35.         Debug.Print "Day Before Was First of Month"
    36.     ElseIf DateBeforeThat = Firstofmonth And ThisDay = "Monday" Then
    37.         Debug.Print "Day Before That Was First of Month"
    38.     End If
    Last edited by rory; May 15th, 2006 at 04:15 AM.

  4. #4
    PowerPoster
    Join Date
    May 2006
    Posts
    2,988

    Re: DB Backup and Restore

    so your code would look like this ..

    VB Code:
    1. Private Sub PromptBackup()
    2.  
    3.     Dim Firstofmonth As Date
    4.     Dim DateBefore As Date
    5.     Dim DateBeforeThat As Date
    6.     Dim ThisDay As String
    7.    
    8.     Firstofmonth = DateAdd("d", 1, Date - Day(Date))
    9.     DateBefore = DateAdd("d", -1, Date)
    10.     DateBeforeThat = DateAdd("d", -2, Date)
    11.     ThisDay = Format(Now, "dddd")
    12.    
    13.     If Date = Firstofmonth Or _
    14.        DateBefore = Firstofmonth And ThisDay = "Monday" Or _
    15.        DateBeforeThat = Firstofmonth And ThisDay = "Monday" Then
    16.             MsgBox "You need to Back up your Database"
    17.             frmBackup.Show vbModal
    18.     End If
    19.  
    20. End Sub

Posting Permissions

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



Click Here to Expand Forum to Full Width