Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 19th, 2003, 02:20 PM
Friend of Wrox
 
Join Date: Nov 2003
Location: Lehigh Acres, FL, USA.
Posts: 625
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to jemacc
Default Access Form

Hi Everyone,

I am trying to display a previous day information and calculate the current date information only and display in on a form.

For Example
[u]FieldName</u> [u]Date</u> [u]Difference</u>
1000 12-19-2003 (First Entry) result from previous
1050 12-20-2003 (second Entry) result from previous
1150 12-21-2003 (Last Entry) result from Previous

In the form I will like to only display the previous date information and the current date information. On monday I make my first entry " 1000","12-19-2003" on the tuesday I make my second Entry "1050", "12-20-2003". On the Difference field name I will like to calculate the difference from previous date First entry "1000-Previous entry, second entry "1050-1000" last entry "1150-1050".

I hope that I was descriptive enough to paint a picture. Any help will be greatly appreciated. Remember it must always calculate the previous date entry only. Thanks everyone.

__________________
Jaime E. Maccou
Reply With Quote
  #2 (permalink)  
Old December 21st, 2003, 05:38 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Melbourne, Vic, Australia.
Posts: 308
Thanks: 0
Thanked 0 Times in 0 Posts
Default

If the previous date is always the most recent date before the one you're entering - you could use a DMax to get it. (look up dmax in Access help)

Steveb

I am a loud man with a very large hat. This means I am in charge
Reply With Quote
  #3 (permalink)  
Old December 21st, 2003, 06:01 AM
Authorized User
 
Join Date: Nov 2003
Location: Paola, Europe, Malta.
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I hope this will help.

Private Sub Form_Load()
   Dim rsPrevious as recordset
   Dim rsCurrent as recordset
   Dim strSql as string
   Dim lngPrevious as long
   Dim lngCurrent as long
   Dim lngDifference as long

   strSql= "SELECT Field FROM Table WHERE Date = "
   Set rsPrevious = CurrentDb.OpenRecordSet(strSql _
                                        & DateAdd("d",-1,Date()))
   lngPrevValue = rsPrevious!Field
   rsPrevious.Close

   Set rsCurrent = CurrentDb.OpenRecordSet(strSql _
                                        & Date())
   lngCurrValue = rsCurrent!Field
   rsCurrent.Close

   lngDifference = lngCurrent - lngPrevious
   txtDifference = lngDifference
End Sub

If you are using a bound form put this code in the Form_current event.

Reply With Quote
  #4 (permalink)  
Old December 22nd, 2003, 03:34 PM
Friend of Wrox
 
Join Date: Nov 2003
Location: Lehigh Acres, FL, USA.
Posts: 625
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to jemacc
Default

I will try this and get back to you with the results.

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
get outside form access angelboy C# 2005 1 September 10th, 2007 03:57 AM
Access Report from Access PivotTable Form Odeh Naber Access 2 July 24th, 2007 09:33 AM
Access form to web form clott BOOK: Access 2003 VBA Programmer's Reference 0 February 13th, 2006 06:44 PM
Resize Access main window from Access form hasseh Access VBA 2 October 24th, 2004 05:15 PM
A Access Form issue goels Access VBA 6 October 7th, 2004 06:58 AM



All times are GMT -4. The time now is 11:33 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.