Code.GeekInterview.com
  I am new, Sign me up!
 
Code Samples MS Access
 

Increment and Decrement Date Value using hot Keys + / -


Code ResourceAuthor: Shivanna  

Difficulty Level:

Published: 25th May 2007   Read: 1345 times  

Filed in: MS Access
Add Comment


 


There are situations where data entry operators need to change date value.  This custom made function helps the users to quickly edit the date field using plus key (+) to increment the date value by one day and minus key (-) to decrement the date value by 1 day. The function provided below takes in date value as one of its argument along with keyCode and Shift, both of which are directly transfered from the OnKeyDown event procedure parameters. This function has to be called from the date field OnKeyDown event.

 


Sample Code
  1.  
  2. Public Function PDate(PObj As Object, KeyCode As Integer, Shift As Integer)
  3. If KeyCode = vbKeyAdd Then
  4.     If Shift = 2 Then
  5.         PObj = DateAdd("m", 1, PObj)
  6.         KeyCode = 0
  7.     Else
  8.         PObj = DateAdd("d", 1, PObj)
  9.         KeyCode = 0
  10.     End If
  11. End If
  12.  
  13. If KeyCode = vbKeySubtract Then
  14.     If Shift = 2 Then
  15.         PObj = DateAdd("m", -1, PObj)
  16.         KeyCode = 0
  17.     Else
  18.         PObj = DateAdd("d", -1, PObj)
  19.         KeyCode = 0
  20.     End If
  21. End If
  22. End Function
  23.  
  24. Example for calling PDate function
  25. Private Sub Invoice_Date_KeyDown(KeyCode As Integer, Shift As Integer)
  26.     PDate Me.Invoice_Date, KeyCode, Shift
  27. End Sub
  28.  
  29. Whenever user hits + or - in the Invoice_Date field, the value of Invoice Date changes accordingly
  30.  
Copyright GeekInterview.com


Next: Show Print Preview Option before printing


 

Latest Code Samples

 

Popular Code Samples

 

Related Code Samples

 

Post Comment


Members Please Login

Name:  Email: (Optional. Used for Notification)

Title:
 
Comment:
Validation Code: <=>  (Enter this code in text box)





Popular Coders

# Coder NameHits
1. Lokesh M4413
2. Shivanna2234
3. Rajani1515

Active Coders

# Coder NameCodes
1. Shivanna2
2. Lokesh M2
3. Rajani1

Refined Tags

 

Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact  

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape