Results 1 to 2 of 2
  1. #1
    cheeese is offline Novice
    Windows 7 64bit Access 2000
    Join Date
    Mar 2011
    Posts
    1

    how do i check against a table?

    Hi



    I have to create a database for a library loan system. This system has got to be able to calculate the date that the book has to be returned. It has to be on loan for 14 days as well as the day it was loaned. That bit is simple however i also have to make sure the due date doesnt fall on a weekend or one of the holiday dates that are in a separate table.

    I was given a bit of visual basic code that worked in a very similar database however i have had no joy in doing this and i cant seem to create an expression that will do the same thing. I dont have that much knowledge of MS Access so any help would be greatly appreciated.

    Thanks

  2. #2
    Join Date
    Mar 2011
    Posts
    15
    Interesting problem, why not try
    Code:
    Private sub boolValidReturnDate(testDate as date) as boolean
     Dim iDay as integer
    
     IDay = weekday(testDate, vbMonday)
    
     boolValidReturnDate = true
    
     If iDay = 6 then boolValidReturnDate = false
     If iDay = 7 then boolValidReturnDate = false
     If not isnull( dlookup("testdate", "otherTable") ) then
      boolValidReturnDate = false
     End if
    End sub
    
    Private function dateReturn(dateLoan as date) as date
     Dim i as integer, dateFortnight as date
     i=0
     
     DateFortnight = dateadd("d", 14, dateLoan)
    
     Do while not boolValidReturnDate( dateAdd("d", I, dateFortnight) )
      I = i + 1
     Loop
     
     boolValidReturnDate = dateAdd("d", i, dateFortnight)
    End function
    Sorry if that doesn't work, I'm on my phone ..

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

Similar Threads

  1. Dynamic Check Boxes values from table
    By ktmjamal in forum Forms
    Replies: 1
    Last Post: 02-21-2011, 07:49 AM
  2. Replies: 3
    Last Post: 11-03-2010, 09:53 AM
  3. How do I add multiple table entries using check boxes?
    By avarusbrightfyre in forum Access
    Replies: 3
    Last Post: 10-21-2010, 01:09 PM
  4. Check if value exist in a table
    By Lucas83 in forum Programming
    Replies: 2
    Last Post: 06-02-2010, 11:42 AM
  5. Replies: 0
    Last Post: 04-19-2008, 09:08 PM

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