Results 1 to 13 of 13
  1. #1
    robsworld78 is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Posts
    181

    Set Database to Expire in time period

    Hi, I can't seem to find this anywhere, is it possible to set a database to expire in say a couple days or whatever.



    I'm trying to sell this database I'm making to someone and want to give them a trial version to try before buy. I want to set the database to expire in a couple days, no locking out features or anything fancy.

    When a date comes, have a form pop-up that says expired and all that good stuff and all a person can do is exit. I know it's simple but not sure where to put in the command.

  2. #2
    SoftwareMatters is offline Access VBA Developers
    Windows XP Access 2003
    Join Date
    Mar 2009
    Location
    Dorset
    Posts
    274
    You should be able to do this on the open event of the form that is set to open when the database opens - you choose this from the Tools/Startup menu.

    Then as you say just put a pop-up msgbox up that then closes the database after ok has been clicked.

  3. #3
    robsworld78 is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Posts
    181
    That sounds good, I do have a form opening when the database starts. Do you know what command I would use in the on open event?

  4. #4
    robsworld78 is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Posts
    181
    If I use the following code it will open the employees form on open however it does it now, it shouldn't until june 10?

    Private Sub Form_Open(Cancel As Integer)
    DoCmd.OpenForm "employees", acNormal, , "[Date]" = "#6/10/2011#"
    End Sub

  5. #5
    SoftwareMatters is offline Access VBA Developers
    Windows XP Access 2003
    Join Date
    Mar 2009
    Location
    Dorset
    Posts
    274
    If you wanted the database to say expire in 1 week from today then do something like this on the OnOpen:

    If Date() >= "#14/06/2011#" Then
    MsgBox ("This databse has expired.")
    DoCmd.Quit
    End If

  6. #6
    robsworld78 is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Posts
    181
    that does do exactly what I want, thank-you, just need some tuning though. When I add that code it expires the db right now, it shouldn't until the 14th? I played with it but couldn't get anything different.

  7. #7
    robsworld78 is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Posts
    181
    I just realized VB is removing the () after date, it always changes it back to

    If Date >= "#14/06/2011#" Then

    So now I'm guessing its reading the Date as right now.

  8. #8
    SoftwareMatters is offline Access VBA Developers
    Windows XP Access 2003
    Join Date
    Mar 2009
    Location
    Dorset
    Posts
    274
    Access is always a bit funny with dates and they way it reads them so to be sure you could force-format them as follows:

    If Format(date, "dd/mm/yyyy") >= Format("14/06/2011", "dd/mm/yyyy") Then
    MsgBox ("This database has expired.")
    DoCmd.Quit
    End If

  9. #9
    robsworld78 is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Posts
    181
    brilliant, thank-you so much! Just when I thought I was starting to figure it out. Crazy you need a string so long.

  10. #10
    robsworld78 is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Posts
    181
    I jumped the gun it still doesn't work properly. That 14th date works and then I changed it to the 6th yesterday and it was expired so I figured all good. Then I changed the date to the 8th and it said expired, the only dates that don't expire it is the 13th and 14th, anything 12th and under it says expire.

  11. #11
    SoftwareMatters is offline Access VBA Developers
    Windows XP Access 2003
    Join Date
    Mar 2009
    Location
    Dorset
    Posts
    274
    Hmm that doesn't sound right. Are you using the exact same code?

    The problem is when Access interprets the day and month the wrong way round e.g. 07/06/2011 as 06/07/2011 but why it doesn't work for 12/06/2011 I don't know because this would be 06/12/2011 which is still in the future.

  12. #12
    robsworld78 is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Posts
    181
    yeah I'm using the exact code, right now I have it set for the 13th which I have a feeling will expire at midnight tonight since that's the last day it would accept. I packaged it up and will see what happens, if that works, I can just do the math, no big deal, I'll let you know.

  13. #13
    robsworld78 is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Posts
    181
    Oh and one time when I opened the form and it gave an error saying the on open event had problems. I opened the form in design, went to the on open event opened it and closed it saved it and it seems good again, it was strange.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Allow a period in a table field name
    By escapades_access in forum Database Design
    Replies: 9
    Last Post: 07-08-2011, 09:21 AM
  2. Obstruct database after A specified time
    By d_Rana_b in forum Programming
    Replies: 3
    Last Post: 04-04-2011, 07:35 AM
  3. Help in Solving Warranty Period in Access
    By vdanelia in forum Access
    Replies: 4
    Last Post: 01-29-2011, 04:28 PM
  4. Count Items by Time Period
    By pawslover in forum Queries
    Replies: 1
    Last Post: 11-15-2010, 03:57 PM
  5. PTO Time Management Database
    By Stanggirlie in forum Programming
    Replies: 1
    Last Post: 03-27-2009, 09:33 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