Results 1 to 9 of 9
  1. #1
    Join Date
    Mar 2004
    Posts
    361

    Unanswered: Need help writing code.

    Hi everyone. I need some help writing code for a few buttons. Right now I have build a form that queries info off a table by allowing the user to search by a unique number. Once that item is returned on the form the user is allowed to update other text boxes on the form. Once the user finishes I need a button to write all of the data or just the user input data as well as an exit button. I have used the wizard but the exit button writes the data to the table. The write button works just fine. So if anyone has any coding experience please let me know. Thank you very much. I will be happy to post the code to each button if you need.

  2. #2
    Join Date
    Apr 2004
    Location
    Kingsland, Georgia
    Posts
    231

    Re: Need help writing code.

    Originally posted by tjarvas
    Hi everyone. I need some help writing code for a few buttons. Right now I have build a form that queries info off a table by allowing the user to search by a unique number. Once that item is returned on the form the user is allowed to update other text boxes on the form. Once the user finishes I need a button to write all of the data or just the user input data as well as an exit button. I have used the wizard but the exit button writes the data to the table. The write button works just fine. So if anyone has any coding experience please let me know. Thank you very much. I will be happy to post the code to each button if you need.
    I do most everything primarily in code, so i'd love to help. i don't understand the "I need a button to write all of the data" followed by "the exit button writes the data to the table." where is the button you need supposed to write to? thanks.

  3. #3
    Join Date
    Mar 2004
    Posts
    361
    Actually, all that I need at this point is a button the close the form without don't anything else. Right now the exit button copies all of the data the was added to the form onto a table that is associated with the form. Maybe that will help.

  4. #4
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    if you are using a bound form (you are) then it's all or nothing - you can either save the current status of all fields on the form, or you can cancel all the user's updates. (actually, there is a way to kill some edits not others, but it's ugly)

    if you want to play field by field, you should use an unbound form... that way you can decide which user-edits to save.



    to get to grips with this, make a fake "unbound form" on a bound form.

    make a second set of textboxes etc to match the set you curently have (a copy/paste will do it).
    then, in properties¦data delete the Control Source entries for your new set ...your new set are now unbound.
    from here you can fill your unbound boxes with the data from their bound counterparts using a suitable event _current() works well.
    unboundbox = boundbox
    for all the boxes. the user now plays happily with the unbound boxes (cos you have hidden the bound counterparts). when you come to save, you decide for how many of the boxes you do a
    boundbox = unboundbox
    there are many other strategies for filling/saving the unbound boxes, but this apparently stupid duplication of boxes actually works rather well and instantly makes clear the difference between bound and unbound.

    izy
    currently using SS 2008R2

  5. #5
    Join Date
    Mar 2004
    Posts
    361
    wow, that seems like a pain in the tail for an issues that seems so simple. I will try this after lunch. I will let you know how it turns out.

  6. #6
    Join Date
    Mar 2004
    Posts
    361
    Can you tell me where to put the event _current() or the boundbox = unboundbox. I was looking in the unbound text box I created and I couldn't find that property.

  7. #7
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    _current() is a form event.

    nothing stops you using _before/after update() but that's field-by-field.


    possible scenario: place a checkbox on the form (you will hide it later) named mustSave

    in _Load() ...form event do
    'do the unbound = bound stuff
    mustSave = false

    in _dirty() ...form event do
    mustSave = true

    in yourSaveRoutinewhateverItIsCalled()
    'do your careful selection of bound = unbound stuff
    'do the save stuff
    mustSave = False



    i'm using shorthand!
    bound = unbound
    means you type
    theRealNameOfTheBoundTextBox = theRealNameOfTheUnboundTextBox



    have a good evening! izy
    Last edited by izyrider; 04-19-04 at 16:29.
    currently using SS 2008R2

  8. #8
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    ....and NO, my last suggestion wont work at all, because _dirty() will not be triggered when your user edits the unbound boxes.

    so... slight modification of the plan: in _AfterUpdate() of each unbound box -
    mustSave = true

    and forget:
    in _dirty() ...form event do
    mustSave = true



    izy
    currently using SS 2008R2

  9. #9
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    you can use _Current() in place of _Load()

    depends:

    current() happens each time you get a new record into the form (this is not a techincal description!!!)

    and _Load() happens each time you load the form (duh!!!)

    izy


    !!! and that's it - i'm definitely off for a glass of wine or three now
    currently using SS 2008R2

Posting Permissions

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