none
setting default values on an input form

    Question

  • hi,

    im trying to make an input form that has 3 fields, Item, Cost, and serial number. The guy im making it for wants to make it so that if he gets 15 of the same item he can put in default values for item and cost, and leave serial number blank as that changes. I was thinking of putting in a button, when onclick it takes the values of the textboxes/controls and sets the textboxes default values to those values, and then another button that clears those default gvalues back to nothing when they are done. Any idea how to do this code wise? Thanks.

    Wednesday, July 20, 2011 1:15 PM

Answers

  • The way that I've done something similar to this in the past is I set up invisible unbound text boxes on the form.  Upon form "before update" and if the form passes validation, I fill in those text boxes with the values from the form which represent the "new default" values.  Then in the "on current" event, I check to see if the current record is a new record, if it is, I automatically populate those fields with the values from the invisible text boxes and set focus to the text box that will hold the unique value, in your case the serial number.  I have the form property set to cycle the current record so if the user doesn't want to use the default value, all they need to do is tab around the form and put in their values.  I don't know how often your user will want to use the default values, but in my case it is most of the time, therefore having a button would be an extra and unnecessary step.  If in your case it is rarely, then a button may be a good idea, but saving the values to the invisible unbound text boxes can still be used as your method to retrieve the "default" data.
    For the benefit of others, please mark posts as answered or helpful when they answer or assist you in finding the answer. ...Sail away from the safe harbor. Catch the trade winds in your sails. Explore. Dream. Discover. - Mark Twain
    • Marked as answer by Lemmy Winks Wednesday, July 20, 2011 2:50 PM
    Wednesday, July 20, 2011 1:39 PM

All replies

  • The way that I've done something similar to this in the past is I set up invisible unbound text boxes on the form.  Upon form "before update" and if the form passes validation, I fill in those text boxes with the values from the form which represent the "new default" values.  Then in the "on current" event, I check to see if the current record is a new record, if it is, I automatically populate those fields with the values from the invisible text boxes and set focus to the text box that will hold the unique value, in your case the serial number.  I have the form property set to cycle the current record so if the user doesn't want to use the default value, all they need to do is tab around the form and put in their values.  I don't know how often your user will want to use the default values, but in my case it is most of the time, therefore having a button would be an extra and unnecessary step.  If in your case it is rarely, then a button may be a good idea, but saving the values to the invisible unbound text boxes can still be used as your method to retrieve the "default" data.
    For the benefit of others, please mark posts as answered or helpful when they answer or assist you in finding the answer. ...Sail away from the safe harbor. Catch the trade winds in your sails. Explore. Dream. Discover. - Mark Twain
    • Marked as answer by Lemmy Winks Wednesday, July 20, 2011 2:50 PM
    Wednesday, July 20, 2011 1:39 PM
  • sounds good ill try it.
    Wednesday, July 20, 2011 2:26 PM