Creating a transit calculator ( Adding a number to a Date)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MikeT614
    New Member
    • Jun 2013
    • 2

    Creating a transit calculator ( Adding a number to a Date)

    I am trying to create a transit calculator as a tool for the database at my freight forward company.

    I have two fields that are manual entry

    Current time: 1500
    Miles Out 500

    These calculate our transit time:

    Transit (500/50mph)= 10hrs*60 = 600min

    What I am trying to do is take that transit time (in minutes) and add it to current time to give a projected ETA.

    I have tried Dateadd("N",[Transit],[Current Time] and keep getting #Name? as the result...

    I'm all ears for options, but keep in mind I'm not good with VBA.. Thank you in advance.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Please show us your VBA code.

    Comment

    • zmbd
      Recognized Expert Moderator Expert
      • Mar 2012
      • 5501

      #3
      Agreed with Rabbit; however, before you do so, please follow the instructions here >> Before Posting (VBA or SQL) Code. You may very well solve your issues. Please remember that you will have to repeat the compile step many times as the compiler stops on the first mistake it finds.

      Comment

      • MikeT614
        New Member
        • Jun 2013
        • 2

        #4
        I was really hoping I could just create an equasion to calculate this through the control source... Is that not possible?

        I'm just not sure why the formula works like this

        Code:
        =DateAdd("n",600,#6/21/2013 3:00:00 PM#)
        But will not work like this..

        Code:
        =DateAdd("n",[Transit],[Current Time])
        Last edited by zmbd; Jun 21 '13, 05:25 PM. Reason: [Z{Please use the [CODE/] formatting button to format your posted code and SQL}]

        Comment

        • Rabbit
          Recognized Expert MVP
          • Jan 2007
          • 12517

          #5
          You can. Assuming of course that [Transit] and [Current Time] exists in the record source, is spelled correctly, is the correct data type, and is not attempting to be referenced within the SQL that it was created.

          We don't have nearly enough information from you to confirm any of the points above.

          Comment

          • zmbd
            Recognized Expert Moderator Expert
            • Mar 2012
            • 5501

            #6
            - In the table, what datatype are the fields [Transit] and [Current Time] set to?

            - You can certainly use the control source to do this.

            - "#Name?" errors in the control source indicate that you've a typo or have not referenced something correctly:
            I see #Name? displayed in a control (Access 2003) (note that though the link is for 2003, this is still the case in newer versions).

            - Also, you started out giving the impression that you were doing this via VBA code not as an equation for a control source; thus, the reason we were asking for you to show your code. The help is still there, just the approach we need to take to help trouble shoot the issue is much different. Keep in mind that the more pertinent information you provide (i.e. ... I'm trying to use the following in the control source... to calculate... (etc)) the better and sooner our answers can help.
            Last edited by zmbd; Jun 21 '13, 05:50 PM. Reason: [z{ blast it... cross posted with Rabbit. Ever the Turttle I am :) }]

            Comment

            Working...