Results 1 to 12 of 12

Thread: Input Box

  1. #1
    Join Date
    Sep 2008
    Posts
    101

    Unanswered: Input Box

    I have a macro running which when clicked it sets values to certain fields what i need is if the date and time need to be rearranged for a callback i have an inputbox show up on screen and it asks for what values certain fields need to be changed to
    i.e
    inputbox asking date
    input box asking time
    and then it sets the values for the fields from what you've entered.
    thanks

  2. #2
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Do you mean several inputboxes or a custom inputbox that asks all the questions at one time?

    One is easy, the other is a tad more complex.

    UserResponse = InputBox("Hey, user, enter the date!","Enter Date")

    Very basically, that will ask a question of a user and pass whatever the user enters into UserResponse. I'm not sure how much of this much can be done with Macros though, I never use them... unless I have to.
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  3. #3
    Join Date
    Sep 2008
    Posts
    101
    Its not transferring what i type into the field?
    in my macro i have a run code action [Preferred Contact Date] = InputBox("Enter Date in dd/mm/yy","Enter Date")
    any ideas?
    or how would i have this run off a button click instead?

  4. #4
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    No error message?

    Code:
    Me.[Preferred Contact Date] = InputBox("Enter Date in dd/mm/yy","Enter Date")
    At the most basic level, this will get the user's answer and store it in a control on your form called "Preferred Contact Date". You might have to deal with data type conversion, depending on your field's data type.

    BTW, it's much better to not have spaces in fieldnames.
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  5. #5
    Join Date
    Sep 2008
    Posts
    101
    can this be added to the macro? or does it need to be on event of the button click? if so is there a way to have it to come up with a second box for the time? and inputs both data into the selected fields
    thanks

  6. #6
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Well that's where I struggle. I basically never use macros, so I don't know.

    I would just set it up as an event procedure for on click.

    The main problem I have with macros is their disparity. You cannot search for all locations where you have used a specific macro name... you have to examine every object's event procedures instead. All VBA code is centrally located, you can search all VBA code everywhere for the name of something and find it.

    Then there's the flexibility!!

    Anyway...

    I haven't really prompted for a date and time in separate boxes, but I would imagine that you would add them to get the result:

    Code:
    Dim dtDate as Date
    Dim dtTime as Date
    
    dtDate = InputBox("Enter the date:", "Enter a date")
    dtTime = InputBox("Enter the time:", "Enter a time")
    
    Me.[Preferred Contact Date] = dtDate + dtTime
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  7. #7
    Join Date
    Sep 2008
    Posts
    101
    when i have this on click event procedure it gives me a message saying type mismatch?

  8. #8
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    That code is like ... vapourware... I haven't tested it, but it should lead you in the right direction!

    I suspect you might need to incorporate # symbols or use CVDate() but I won't advise you right now... too drunk

    It's my birthday!

    One of the other guys will help you sort out the data type mismatch issue... please!!
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  9. #9
    Join Date
    Sep 2008
    Posts
    101
    Happy birthday startrekker and thanks dude

  10. #10
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Thanks and you're welcome

    What data type is your [Preferred Contact Date] field?

    Which line is it stopping on? Might have to use strings and convert to a date later.
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  11. #11
    Join Date
    Sep 2008
    Posts
    101
    the data type is dd/mm/yyyy

  12. #12
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    UserResponse = InputBox("Hey, user, enter the date!","Enter Date")
    in my books that's a baaad approach.
    you don't know if the user is entering valid data

    its far better in my books to have a parameter setting form where you can validate that information is accurate and reasonable before letting it loose in your queries or reports

    what I've done in the past is to have a switchboard/menu form which stores such parameters, a child form which sets/validates such parameters (and updates the switchboard form. Because the switchboard should always be open I know any queries,reports or forms will be using validated data. It does mean you have to set up defaults when the application first opens. one of the advantages of this approach is if say you have to run a suite of reports your user can be sure that they are using the same parameters... so there's fewer allegations that your reports are inaccurate or inconsistent because everything is pulled form the same parameter list. it also helps on the debugging, you are running with a consistent set of data so you can check the results using another tool (say SQL) and then validate actual results with forecast results
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

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