Results 1 to 15 of 15
  1. #1
    Join Date
    Mar 2004
    Posts
    52

    Unanswered: Date has to be input after another date...

    Hi,

    I am designing a database for a gym as my final year project.

    I have a purchase order table and a member order table. What I'm trying to do is, if a member places an order on 01/05/04, the purchase order that the gym places for that product has to be after 01/05/05. If a purchase order date is entred before member order, an error has to show up.

    Thanks in advance.

  2. #2
    Join Date
    Mar 2004
    Location
    Nashville, TN
    Posts
    557
    Are these dates on the same form?
    Have you ever thought about thinking on purpose?

    Jarvis Stubblefield
    Patriot Designs
    Web/Database Development and Consulting
    The-Patriot.net by Patriot Designs

  3. #3
    Join Date
    Mar 2004
    Posts
    52
    Yes they are. I have used the "look up wizard" to look up the member order date.

  4. #4
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    You can evaluate dates just like any other value.

    If orderDate < DATEADD("y", 1, startDate) Then
    'errorstuff
    else
    whatever
    end if

  5. #5
    Join Date
    Mar 2004
    Posts
    52
    Originally posted by Teddy
    You can evaluate dates just like any other value.

    If orderDate < DATEADD("y", 1, startDate) Then
    'errorstuff
    else
    whatever
    end if
    Teddy i assume I type this in the Validation rule?

    When I do I get an error message saying "You many have entered an operand without an operator."

  6. #6
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    That would be vba code for one of the events.

    I haven't tried this as a validation rule, but you may be able to use just the dateadd function, I'm not sure if you can reference another field in the same record or not.

  7. #7
    Join Date
    Mar 2004
    Posts
    52
    Originally posted by Teddy
    That would be vba code for one of the events.

    I haven't tried this as a validation rule, but you may be able to use just the dateadd function, I'm not sure if you can reference another field in the same record or not.

    I have never used a VBA code before. So how would I go about accessing it.

  8. #8
    Join Date
    Mar 2004
    Posts
    52
    Originally posted by JSThePatriot
    Are these dates on the same form?
    JS could you please explain where I type this code in Vb?

  9. #9
    Join Date
    Mar 2004
    Posts
    52
    Originally posted by Teddy
    That would be vba code for one of the events.

    I haven't tried this as a validation rule, but you may be able to use just the dateadd function, I'm not sure if you can reference another field in the same record or not.
    Teddy, I have tried the code that you have given and get the following error message:

    Compile error:

    Sub or function not defined.

    The 'whatever' is highlighted. What shall I change?

  10. #10
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Well, logic says change the "whatever" to "whatever" code you'd like to trigger if the statement is false.


  11. #11
    Join Date
    Mar 2004
    Posts
    52
    Originally posted by Teddy
    Well, logic says change the "whatever" to "whatever" code you'd like to trigger if the statement is false.

    Ok Teddy this is what I have:

    Private Sub Date_Enter()
    If MemberOrderDate < DateAdd("y", 1, StartDate) Then
    'errorstuff
    Else
    'Enter New Date'
    End If



    End Sub

    But its still not working. What does Teddy/logic say now?

  12. #12
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Originally posted by hali99
    Ok Teddy this is what I have:

    Private Sub Date_Enter()
    If MemberOrderDate < DateAdd("y", 1, StartDate) Then
    'errorstuff
    Else
    'Enter New Date'
    End If



    End Sub

    But its still not working. What does Teddy/logic say now?
    haha.

    You're getting an error from that? What error, on what line?

  13. #13
    Join Date
    Mar 2004
    Posts
    52
    Originally posted by Teddy
    haha.

    You're getting an error from that? What error, on what line?
    It says

    Compile error:

    Syntax error.

    And then it highlights Enter New Date. Then when I click on OK it highlights

    Private Sub Date_Enter()

  14. #14
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    There's no possible way for the control structure to be bombing.

    You must have something implemented funny.

    If condition Then
    else
    end if

    that's not hte issue.

    Try debugging your values before it hits that if statement

    msgbox str(DateAdd("y", 1, StartDate) ) & " " & MemberOrderDate
    Last edited by Teddy; 04-15-04 at 17:06.

  15. #15
    Join Date
    Mar 2004
    Posts
    52
    Originally posted by Teddy
    There's no possible way for the control structure to be bombing.

    You must have something implemented funny.

    If condition Then
    else
    end if

    that's not hte issue.

    Try debugging your values before it hits that if statement

    msgbox str(DateAdd("y", 1, StartDate) ) & " " & MemberOrderDate
    Ok, Maybe I am placing the code in the wrong place.

    This is what I am doing after I read through a book.

    Going to design view of Purchase Order form.

    Right click on purchase order date and clicking on properties and then clicking on the Event tab.

    In the On Enter option I type the code. Anything wrong with that?

Posting Permissions

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