Results 1 to 3 of 3
  1. #1
    robsworld78 is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Posts
    181

    If statement with Todays Date being criteria

    Hi, I'm trying to create a button that posts an order and before it post certain criterias need to be meet. One of them is a date needs to be selected in the order, if not a popup show to explain.

    The trouble I'm having is referring to todays date in the VBA code. I've been reading and trying different things but not getting anywhere, hopefully someone can fill me in.

    This is the code I'm working with.

    If [PayOrderMoneyReceivedSubform].[Form]![OrderDate] = TodaysDate Then
    dosomething
    else


    donothing
    end if

    The part I'm having trouble with is TodaysDate, what should I be putting there?

  2. #2
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    Today's date is

    Date

    If [PayOrderMoneyReceivedSubform].[Form]![OrderDate] = Date Then

  3. #3
    robsworld78 is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Posts
    181
    Thanks Bob, I knew it was that or at least I thought it should be. Access just messing around with me again, here's why it didn't work.

    The If statement has a couple And's in it and I added the date last because it was an addition. So this is what didn't work

    If [OrdersOrdersSubform].[Form]![Status] = "PartialPaid" And [PayOrderInvoiceAmountOwingSubform].[Form]![MoneyOwingOnOrderTotal] < 0.01 And [PayOrderInvoiceAmountOwingSubform].[Form]![PaymentDifference] = 0 And [PayOrderMoneyReceivedSubform].[Form]![OrderDate] = Date Then

    And this is what works

    If [PayOrderMoneyReceivedSubform].[Form]![OrderDate] = Date And [OrdersOrdersSubform].[Form]![Status] = "PartialPaid" And [PayOrderInvoiceAmountOwingSubform].[Form]![MoneyOwingOnOrderTotal] < 0.01 And [PayOrderInvoiceAmountOwingSubform].[Form]![PaymentDifference] = 0 Then

    So why does date need to be first? I see it as the exact same string. When this like this occur it makes it very hard, now I wonder how many other things I tried that didn't work and maybe because of something stupid like this. I understand if a ' or ! etc is missing but these are the same lines.

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

Similar Threads

  1. Replies: 12
    Last Post: 12-11-2011, 05:04 PM
  2. Update with Todays Date on Open
    By anoob in forum Forms
    Replies: 5
    Last Post: 03-08-2011, 02:00 PM
  3. Adding todays date
    By EDEd in forum Forms
    Replies: 2
    Last Post: 10-08-2010, 06:27 PM
  4. Passing Criteria to IN statement from Form
    By stephenaa5 in forum Queries
    Replies: 1
    Last Post: 10-09-2009, 04:02 AM
  5. nested if statement with two criteria
    By kendra in forum Queries
    Replies: 5
    Last Post: 06-16-2009, 04:07 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