Results 1 to 14 of 14
  1. #1
    JayX is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Dec 2011
    Posts
    62

    Date/Time code


    Is there a formula or code to put in the date and time in a text box so it updates automatically whenever a button is clicked?

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,043
    Me.TextboxName = Now()
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    JayX is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Dec 2011
    Posts
    62
    actually I only need the date, no time...how do I do that?

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,043
    Ah, a moving target.

    Me.TextboxName = Date()
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    JayX is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Dec 2011
    Posts
    62
    Thank you!

  6. #6
    JayX is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Dec 2011
    Posts
    62
    I have one more scenario...I have 3 buttons right now one that when you click it a input message appears and asks for a value which it then puts that value into a textbox | Me![Total] = Val(InputBox("Please enter a value:")) |, thats the code. Next I have another button that when you press it, it increments by 1 but what I want it to do instead is when you click that button another input message appears asking How much would you like to add to the total inventory and then it adds the number you put in onto what is already there in the textbox...any idea?

    Help would be greatly appreciated

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,043
    Along the lines of

    Me.Textbox = Me.Textbox + InputBox(...)

    I'd probably add some validation of the input first.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  8. #8
    JayX is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Dec 2011
    Posts
    62
    How do I get an Input message to show saying "How much Inventory Received" which then shows that number alone in a separate textbox as well as that number being added to the "total' textbox?

  9. #9
    JayX is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Dec 2011
    Posts
    62
    The code you gave me is adding a 5 at the end of the actual total, how do I get it to do addition to the total, if i enter 5 in the Plus button id like it to go from 500 to 505, as well as just showing a 5 right next to the +1 button.

    Here is a picture

  10. #10
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,043
    If it's concatenating instead of adding, your numbers are being seen as text for any number of reasons (data type, functions, etc). If you can't fix that you can work around it:

    Me.Textbox = CLng(Me.Textbox) + CLng(InputBox(...))

    Or one of the other conversion functions, as appropriate to your situation.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  11. #11
    JayX is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Dec 2011
    Posts
    62
    I put in what I needed to accordingly for it to work in my form but it is giving me an error.. it seemed like it worked at first but then kicked it to an error. At first when I put a 5 in the input box it did add the 5 to 500 making it 505, but it did not show the 5 alone in the textbox next to the + button.

  12. #12
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,043
    What's the error? What's your actual code?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  13. #13
    JayX is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Dec 2011
    Posts
    62
    Code is working the only part that isn't working now is when I hit cancel on the input box 'Run-error '13': Type Mismatch pops up asking me to "end" or "debug" how do i get that to stop

  14. #14
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,043
    Like I said earlier, I'd validate the input first:

    Code:
    Dim varInput as Variant
    varInput = InputBox(...)
    If IsNumeric(varInput) Then
      'Do your thing
    Else
      Msgbox "Input must be a number"
    End If
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Each time I click run different code
    By Dominaz in forum Access
    Replies: 3
    Last Post: 11-14-2011, 08:44 AM
  2. Getting Just the Date part of Date/Time field
    By GaryElwood in forum Reports
    Replies: 7
    Last Post: 09-28-2011, 09:58 AM
  3. Replies: 12
    Last Post: 02-22-2011, 03:39 PM
  4. Replies: 6
    Last Post: 01-04-2011, 05:43 PM
  5. Duplicate Check code with Run-Time error '3079'
    By viper in forum Programming
    Replies: 5
    Last Post: 10-18-2010, 10:12 AM

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