Results 1 to 4 of 4
  1. #1
    bluepowa is offline Novice
    Windows Vista Access 2007
    Join Date
    Sep 2009
    Posts
    2

    How to create warning notice


    Hello, I think this might be ambitious for coding, but it is a warning dialogue box that pop ups when said item is being delivered, this may sound simple, but here are the parameters.

    Database(tracks items being given out to the homeless)

    Toothbrush is given out only once a month and lets assume the database is already set up, but the code to give this warning is not.

    For example person giving out items is about to give out a toothbrush and starts putting the data in, is it possible to have a warning pop out if the person gives out a toothbrush too early to said person, because a month has not transpired since the previous giving out of a toothbrush, so then the person handing out items would know not to give out the toothbrush until later.

  2. #2
    dcrake's Avatar
    dcrake is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Aug 2009
    Posts
    435
    When adding an item to a persons inventory you will need a select case statement to define what type of item is being added. This will determine any rules you have in place for different items. So lets say you selected toothbrush

    Code:
     
    Select Case Item
        Case = "Toothbrush"
           Step 1: lookup the last date that a person was given a toothbrush
           Step 1.1 : No date found - never been given one
                        : Ok to add item
           Step 1:2 : is the DateDiff() between Last Date and Today < 30
           Step 1.3 : No - Ok to give them one
           Step 1.4 : Yes - Warn User with message box about last date issued.
       Case else
    End Select
    Obviously this is all in plain English and used for brevity the actual coding will be needed. But the logic is correct.


    David

  3. #3
    bluepowa is offline Novice
    Windows Vista Access 2007
    Join Date
    Sep 2009
    Posts
    2
    Thanks, I am having issues finding the correct code corresponding to each segment of the logic you posted, sorry I am only working with missingmanuals book on access 2007.

  4. #4
    dcrake's Avatar
    dcrake is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Aug 2009
    Posts
    435
    Code:
     
    Select Case Item
        Case = "Toothbrush"
           Step 1: lookup the last date that a person was given a toothbrush
           Step 1.1 : No date found - never been given one
                        : Ok to add item
           Step 1:2 : is the DateDiff() between Last Date and Today < 30
           Step 1.3 : No - Ok to give them one
           Step 1.4 : Yes - Warn User with message box about last date issued.
       Case else
    End Select
    In detail

    Code:
     
    Dim DtLastIssue As Date
    Dim Elapsed As Integer
        'What was the last date a person was given a toothbrush?
        DtLastIssue = Nz(DMax("[DateIssued]","Inventory","[PrimaryKey]=" ID),0)
     
    Select Case Item
       Case "Toothbrush"
            'No date found
            If DtLastIssue = 0 Then
               'Yes they can have a toothbrush
            Else
               'How many days is it since they were given a brush
               Elapsed = DateDiff("d",DtLastIssue,Date)
               If Elapsed > 30 Then
                  'Yes they can have a toothbrush
               Else
                  'No they can't it was issued in the last 30 days
                  MsgBox "Toothbrush issued on " & DtLastIssued & " (" & Elapsed & " day(s) ago)."
               End If
            End If
      Case Else
     
    End Select

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

Similar Threads

  1. Need to create a new db
    By ori in forum Access
    Replies: 5
    Last Post: 05-26-2009, 05:24 AM
  2. create sequential id
    By proudestmnky1 in forum Programming
    Replies: 0
    Last Post: 12-16-2008, 12:10 AM
  3. Records deleted with NO warning message.
    By evanscamman in forum Access
    Replies: 2
    Last Post: 12-14-2007, 11:18 PM
  4. Security Warning
    By mojo53777 in forum Security
    Replies: 0
    Last Post: 11-16-2007, 06:23 AM
  5. Create the link
    By accessman2 in forum Access
    Replies: 0
    Last Post: 03-13-2006, 01:16 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