Results 1 to 4 of 4
  1. #1
    REAbernathy is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jul 2012
    Posts
    46

    Determining the value of 3 Date/Time Boxes....Newbie


    I imported a excel spreadsheet into an access datebase and in the excel spreadsheet there are 3 fields that allow the user to click inside the box and add a date (KBtoFirms1_CMAS + KBFirms2_CMAS + KBFirms3_CMAS = BatchKBCount_CMAS_DontTouch). On my form i have added 3 text boxes that allow the user to enter a date. What I am trying to do is assign a value to the fields and when a date is added count that as "1" and when the field is empty count that as "0" then place that value in the BatchKBCount_CMAS_DontTouch. For example if KBtoFirms1_CMAS has a date and KBtoFirms2_CMAS has a date and KBtoFirms3_CMAS does not have a date then the value in BatchKBCount_CMAS_DontTouch should equal "2". Can this be done by code or can i do this by using sometype of forumla in the table and if so how do i accomplish this.

    Thanking you in advance for your help and assistance in this matter.

  2. #2
    GeekInOhio's Avatar
    GeekInOhio is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2012
    Posts
    25
    Putting the following in the Before Update events of the three KBtoFirms date fields should do you fine.

    Code:
    Dim myCount As Integer
    
    
    myCount = 0
    
    
    If IsDate(Me.KBtoFirst1_CMAS) Then
        myCount = myCount + 1
    End If
    
    
    If IsDate(Me.KBtoFirst2_CMAS) Then
        myCount = myCount + 1
    End If
    
    
    If IsDate(Me.KBtoFirst3_CMAS) Then
        myCount = myCount + 1
    End If
    
    
    Me.BatchKBCount_CMAS_DontTouch = myCount

  3. #3
    REAbernathy is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jul 2012
    Posts
    46
    GeekinOhio

    Thanks for the quick response however you said add it Before Update events and I am a bit confused about this being that I only have 2 command buttons on my form Save Record and Next Record. Remember I am a Newbie to VBA......

  4. #4
    GeekInOhio's Avatar
    GeekInOhio is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2012
    Posts
    25
    Add it to the Before Update event of the three text boxes. If you want an initial count on record load, you can also add the code to the On Current event of the form.

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

Similar Threads

  1. Replies: 5
    Last Post: 07-01-2011, 11:13 AM
  2. Replies: 12
    Last Post: 02-22-2011, 03:39 PM
  3. Replies: 6
    Last Post: 01-04-2011, 05:43 PM
  4. Replies: 0
    Last Post: 02-26-2009, 03:34 PM
  5. Determining Winners/Losers
    By pfeff in forum Queries
    Replies: 0
    Last Post: 02-21-2008, 03:46 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