Results 1 to 8 of 8
  1. #1
    Join Date
    Nov 2002
    Location
    Belgium
    Posts
    243

    Unanswered: Closing form without updating table

    I have a form containing 5 listboxes.
    When the form loads all combos show a blank field.
    The user selects a value from the listboxes (the first 2 are required) and presses a button to add this record to a table.
    However, when the user fills in 3 (for example) of them, and then decides he wants to close the form WITHOUT storing the last record in the table, he should be able to press the 'close'-button to achieve this.
    I already tried several things, but everytime the record is stored in the table.
    Can anyone help me out?

    Thanx

  2. #2
    Join Date
    Sep 2002
    Location
    Land of OZ
    Posts
    173

    Re: Closing form without updating table

    Originally posted by artemide
    I have a form containing 5 listboxes.
    When the form loads all combos show a blank field.
    The user selects a value from the listboxes (the first 2 are required) and presses a button to add this record to a table.
    However, when the user fills in 3 (for example) of them, and then decides he wants to close the form WITHOUT storing the last record in the table, he should be able to press the 'close'-button to achieve this.
    I already tried several things, but everytime the record is stored in the table.
    Can anyone help me out?

    Thanx
    Simple line of code on the close button should do this ... if I have understand your problem correcly

    Docmd.RunCommand accmdUndo
    Mona
    ________________________________
    Life is too short to be sane or sensible. Weird people rule and normal people suck

  3. #3
    Join Date
    Nov 2002
    Location
    Belgium
    Posts
    243

    Red face Re: Closing form without updating table

    I tried that command and that worked, but I also noticed that the situation is a little more complicated the I first thought.

    Simplified version :
    Combobox1 shows the names of the users.
    Combobox2 shows the courses they might follow.
    On my form I also have a subform. As soon as a user is selected, the subform displays all the courses the selected user already followed.
    In that subform I can select one or more records and delete them.

    As long as I open my form and only play with my combo's and then close the form, there's no record added to the table.
    But when (after playing with my combo's) I selected one of the records in the subform and then close the form, the record is added to the table.
    Even if I change something in my combo's afterwards and then close the form.

  4. #4
    Join Date
    Sep 2002
    Location
    Land of OZ
    Posts
    173

    Re: Closing form without updating table

    Originally posted by artemide
    I tried that command and that worked, but I also noticed that the situation is a little more complicated the I first thought.

    Simplified version :
    Combobox1 shows the names of the users.
    Combobox2 shows the courses they might follow.
    On my form I also have a subform. As soon as a user is selected, the subform displays all the courses the selected user already followed.
    In that subform I can select one or more records and delete them.

    As long as I open my form and only play with my combo's and then close the form, there's no record added to the table.
    But when (after playing with my combo's) I selected one of the records in the subform and then close the form, the record is added to the table.
    Even if I change something in my combo's afterwards and then close the form.
    Couple of solutions here.

    1. Change the comboboxes to unbound comboboxes. This will allow you to select items and view the result.
    Add a button to add to table. This will need to be coded. If need be I can mock someting up for this.

    2. Second option is to leave it as it is, and on the close button, check if the sub form was "touched", if so, you will need to run a delete record. This is due to the fact that as soon as you leave the main form, the chages in the main form are saved. Therefore going to a subform, will result in this change taking place.

    3. Third option, If programming is not a stronger pont, I would be creating two separate forms. One for View, and the other for adding. The view form should not have any bound comboboxes, just unbound boxes reading the Name and courses.

    Happy to mock something up if necessary.
    Mona
    ________________________________
    Life is too short to be sane or sensible. Weird people rule and normal people suck

  5. #5
    Join Date
    Nov 2002
    Location
    Belgium
    Posts
    243

    Re: Closing form without updating table

    Hey Mona,

    Choose the first solution and it works fine.

    Thanks a lot.

    Because you helped me so quickly I want to serve you a new question.
    I wrote a SELECT-statement in VB :

    combobox2.RowSource = _
    "SELECT ID, name, typeID FROM table1 " & _
    "WHERE typeID = " & combobox1.Column(0)"

    This works great, but the problem is that the data is ordered by ID and I want them ordered by name.

    So I changed the statement :

    combobox2.RowSource = _
    "SELECT ID, name, typeID FROM table1 " & _
    "WHERE typeID = " & combobox1.Column(0) " & _
    "ORDERED BY name"

    Result : my combobox2 stays empty.

    Any idea ?

    Thanx

  6. #6
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740

    Re: Closing form without updating table

    try

    ORDER BY

    izy

  7. #7
    Join Date
    Sep 2002
    Location
    Land of OZ
    Posts
    173

    Re: Closing form without updating table

    Originally posted by artemide
    Hey Mona,

    Choose the first solution and it works fine.

    Thanks a lot.

    Because you helped me so quickly I want to serve you a new question.
    I wrote a SELECT-statement in VB :

    combobox2.RowSource = _
    "SELECT ID, name, typeID FROM table1 " & _
    "WHERE typeID = " & combobox1.Column(0)"

    This works great, but the problem is that the data is ordered by ID and I want them ordered by name.

    So I changed the statement :

    combobox2.RowSource = _
    "SELECT ID, name, typeID FROM table1 " & _
    "WHERE typeID = " & combobox1.Column(0) " & _
    "ORDERED BY name"

    Result : my combobox2 stays empty.

    Any idea ?

    Thanx

    Its ORDER BY Instead or ORDEDED BY ... and also check your spaces

    combobox2.RowSource = _
    "SELECT ID, name, typeID FROM table1 " & _
    "WHERE typeID = " & combobox1.Column(0) " & _
    " ORDER BY name"



    Cheers
    Mona
    Mona
    ________________________________
    Life is too short to be sane or sensible. Weird people rule and normal people suck

  8. #8
    Join Date
    Nov 2002
    Location
    Belgium
    Posts
    243

    Re: Closing form without updating table

    Originally posted by mona
    Its ORDER BY Instead or ORDEDED BY ... and also check your spaces

    combobox2.RowSource = _
    "SELECT ID, name, typeID FROM table1 " & _
    "WHERE typeID = " & combobox1.Column(0) " & _
    " ORDER BY name"



    Cheers
    Mona
    Hey Mona,

    I did use the ORDER-statement (one way or another I mistyped).
    But, anyway, you were right about the spaces.

    Thanks a lot

    artemide

Posting Permissions

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