473,386 Members | 1,738 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Set expiration date in MS access

I want to set an expiration date in MS Access exacly in VBA on open form, beginning from actual Date to 30 days, or 1 year. i have this code :
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Open(Cancel As Integer)
  2. if date>= "#June 10th 2014#" then
  3.    msgbox("Sorry Evaluation Period Expired")
  4.    cancel = true
  5.    Exit sub
  6. end if
  7. End Sub
But i want to add 30 days from now,(actual date) and appear a message box that says: Sorry Evaluation Period Expired
Feb 14 '14 #1
6 7362
mcupito
294 256MB
I'm confused. What date to you want to use? 1 year or 30 days?

"I want to add 30 days from now" .. So is the 1 year no longer relevant?

If I used your code and changed it to 30 days from now, I would write it like this:

Expand|Select|Wrap|Line Numbers
  1. Dim dt As Date
  2.  
  3. dt = [YourDateField]
  4.  
  5. If dt >= DateAdd("d", 30, Date) Then
  6. MsgBox("Sorry Evaluation Period Expired")
  7. End If
Feb 14 '14 #2
NeoPa
32,556 Expert Mod 16PB
Kushtrim.

You have posted air-code. That is - code that is not compiled or workable or has ever been taken from your code. This is simply stuiff you've typed into the post.

Please don't do that is it is soooo wasteful of the time and effort of our experts. Take the trouble to test it properly first before posting it in here.

See Before Posting (VBA or SQL) Code for why this is not acceptable.
Feb 15 '14 #3
neelsfer
547 512MB
i use a "currentdate" textbox on the startup form and then use this code in the load event.
Expand|Select|Wrap|Line Numbers
  1. If Me.CurrentDate >= DateAdd("d", 30, Date) Then
  2. MsgBox "This program needs to be reinstalled as it has expired."
  3. DoCmd.Quit
Ensure that this code is ONLY added to a COPY of your original application, or you will never open it again!!!!
Feb 18 '14 #4
NeoPa
32,556 Expert Mod 16PB
You'd typically want a value that's stored somewhere Neels. I doubt you're suggesting CurrentDate should be stored within the design of the form, yet otherwise your suggestion makes little sense.

The value would need to reflect the release date. Date() already gives you the current date. It's possible to store the release date in a table, but that would be so easy to manipulate unless it were encrypted. An alternative to storing it in the database that many people like, is to store it somewhere in the Windows Registry. This option makes finding it less straightforward for someone trying to circumvent the process. There's no reason why this, too, shouoldn't be encrypted.

Thus, the code for something like this (in very general terms) might be :
Expand|Select|Wrap|Line Numbers
  1. If DateAdd("m", 3, GetReleaseFromReg()) < Date() Then
  2.     Call MsgBox(Prompt:="License has expired.  Please contact ... for renewal" _
  3.               , Buttons:=vbOKOnly Or vbInformation _
  4.               , Title:=CurrentProject.Name)
  5.     Call Application.Quit
  6. End If
GetReleaseFromReg() would be a function that returns the release date.

NB. The comparison must be Less Than Date() related - Not Greater Than.
Feb 19 '14 #5
neelsfer
547 512MB
Thx Neopa that makes absolutely sense. Sorry i did not think properly. I usually "hardcode" the expirydate into vba when compiling to accde, but your method seems the right way. How would you use this "GetReleaseFromReg()" and get the current date copied into the registry to read it from? (i suppose that is classified info?)
Feb 19 '14 #6
NeoPa
32,556 Expert Mod 16PB
Indeed not, but it is the topic of a separate question.

Feel free to post it and LMK when it's been done and I'll dig out some info for you. It makes sense for something like that not to be hidden away in another thread.

NB. It does use an OS feature (so not found in standard libraries) unless you go with the very basic approach. I'll cover it more fully in the answer when you post the question. Hopefully it'll make better sense there ;-)
Feb 19 '14 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Christophe Lance | last post by:
Hello, I use PHP session cookie to store an id number. I know how to set a cookie expiration date using the setcookie function, but how to set an expiration date when the cookie is created by...
2
by: gardnern | last post by:
Is it possible to get the expiration date/time of a cookie? I need to limit someone to visiting a couple of pages for 45 minutes max and would like to show them how much time they have left. I dont...
0
by: Rock | last post by:
Hi,all: I have find a example to set expiration date of word permission object, but it was using VBA code. Dim objUserPerm As Office.UserPermission Set objUserPerm =...
2
by: Frederic Gignac | last post by:
Hiya all, My buddy and I got a bug with the expiration date of a cookie. When we want to look out the expiration date, the only thing we've got, it's 01/01/0001. As we know, when we want to...
0
by: Diffident | last post by:
Hello All, I cached a string object into Cache and set absolute expiration date. Now, I would like to retrieve the absolute expiration date of that object. Any API's available? Any pointers?...
10
by: Mike9900 | last post by:
Hello, I would like to store application expiration date in a file and store that file in a secure place, so the application can access the file for all the users on that computer. ...
1
by: phillip.s.powell | last post by:
I have a table, "article" that has a datetime field "article_expires". In my SQL statement I have this: SELECT id, title, body FROM article WHERE (article_expires IS NOT NULL OR...
3
by: dave | last post by:
I need to compute an expiration date based on the number of hours, days, or months purchased. The expiration date needs to be expressed in minutes something like '1260481600'. How can I get the...
2
by: Steve Covert | last post by:
Does anybody have any clever technique to implement an expiration date in a WinForms app, such that it could outsmart any user who tries to change the system clock to avoid expiration?
8
by: hatsepsut | last post by:
Hi, I am trying to modify a database that has a form with chemicals,manufacturing date and expiration date. They want the expiration date to be automatic so I used Dateadd in the field. However, in...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.