Results 1 to 6 of 6

Thread: Date controls

  1. #1
    Join Date
    Apr 2009
    Posts
    8

    Unanswered: Date controls

    Hi there,
    i have an ms access database 2007 with two date fields. The first date field is called [Testing date]. The second is called [Confirmatory Test date].
    I want the [confirmatory Test date] to be (>=) greater or equal to [Testing date].
    Thanks
    Timothy

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    so put some code behind both controls and or the form that enforces that business logic.

    I'd suggest you do it as a function that returns true or false if the data is valid

    possible states are (I'm guessing)
    testdate must have a date
    confirm date may have a date, if it is it must be greater than or equal to the testdate


    public function CheckTestDates() as boolean
    CheckTestDates=false 'set up our default return condition
    if isnull([Testing date]) then exit function 'don't dick about we can't have a null test date
    endif
    if not isdate([Testing date]) then exit function 'don't dick about we can't have a non date "test date", can we
    if isnull ([Confirmatory Test date]) = true then
    CheckTestDates=true 'so the confirm date is null, thats ok
    exit function
    endif
    if isdate([Confirmatory Test date]) and [Confirmatory Test date]>= [Testing date] then
    CheckTestDates=true 'so the confirm date is a date and is greater than or equal to the test date, thats ok
    endif
    end function

    you can then call that code whenever you need to
    I'd suggest in the relevant controls on lost focus events, the forms before update event

    how you habdle the return fromt eh fucntion is up to you
    you coudl display a snotty message

    eg
    if CheckTestDates=false then msgbox("Oi dumbass, you've made a reet pigs ear of the test dates")


    you can stop the data being updated by placing the code in the form and or controls before update by setting the cancel flag

    note you need to change the state of the flag

    cancel = not CheckTestDates()


    HTH
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Apr 2009
    Posts
    8
    Thanks Healdem,
    It worked.

  4. #4
    Join Date
    Apr 2009
    Posts
    8
    Hello Healdem,
    What do i need to do in order to count the number of records in a report.I want the function to be incorporated into the Report such that as it displays the records, it also shows the total number of records.
    Thanks
    Timothy

  5. #5
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    new question new thread, dem's dere rules

    however
    the easiest way is to put a control in the relevant footer (group, page, report footer) and set its control source to =count(acolumn) eg count([Testing Date])

    a word of caution try to avoid using spaces in your column names TestingDates doenst' require square brackets around it

    make sure you don't use reserved words for column names.. it can cause chaos in queries, forms and reports. for a list of reserved words Google is your matey.
    I'd rather be riding on the Tiger 800 or the Norton

  6. #6
    Join Date
    Apr 2009
    Posts
    8
    Many thanks healdem,
    It worked like a charm.
    Timothy

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •