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

    Unanswered: Exit Button Writing Table

    Hello everyone, I have a problem. I have a form that allows the user to type in a unique number which then queries info off a table that populates a few text boxes. The user then can add info to a number of other text boxes. At this point the user presses a button and all of that information is writen to a table. I also have an exit button to close the form. Right now the exit button is writing the data to the table as well as the button that is supposed to write the information to the table. Is there a way that I can add a button to the form that just closes the form without writing the data. I will post the code if need be. Thank you very much.

  2. #2
    Join Date
    Mar 2004
    Location
    Nashville, TN
    Posts
    557
    Posting the code would definitely help. Is the form bound or unbound? If it is bound then you need to make it unbound and in the save button put an INSERT Query that inserts all of your data into the proper table, and the exit button just exits the form without inserting the data.

    So UnBound or Bound?

    Please post the code.

    JS
    Have you ever thought about thinking on purpose?

    Jarvis Stubblefield
    Patriot Designs
    Web/Database Development and Consulting
    The-Patriot.net by Patriot Designs

  3. #3
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Originally posted by JSThePatriot
    Posting the code would definitely help. Is the form bound or unbound? If it is bound then you need to make it unbound and in the save button put an INSERT Query that inserts all of your data into the proper table, and the exit button just exits the form without inserting the data.

    So UnBound or Bound?

    Please post the code.

    JS
    Sounds bound to me ... If all the exit button does is call DoCmd.Close ...

  4. #4
    Join Date
    Mar 2004
    Posts
    361
    Here is the code.

    Option Compare Database

    Private Sub Write_Button_Click()
    On Error GoTo Err_Write_Button_Click


    DoCmd.GoToRecord , , acNewRec

    Exit_Write_Button_Click:
    Exit Sub

    Err_Write_Button_Click:
    MsgBox Err.Description
    Resume Exit_Write_Button_Click

    End Sub
    Private Sub Command31_Click()
    On Error GoTo Err_Command31_Click


    DoCmd.GoToRecord , , acNewRec

    Exit_Command31_Click:
    Exit Sub

    Err_Command31_Click:
    MsgBox Err.Description
    Resume Exit_Command31_Click

    End Sub
    Private Sub Command109_Click()
    On Error GoTo Err_Command109_Click


    DoCmd.Close

    Exit_Command109_Click:
    Exit Sub

    Err_Command109_Click:
    MsgBox Err.Description
    Resume Exit_Command109_Click

    End Sub
    Private Sub Write_Table_Click()
    On Error GoTo Err_Write_Table_Click


    DoCmd.GoToRecord , , acNewRec

    Exit_Write_Table_Click:
    Exit Sub

    Err_Write_Table_Click:
    MsgBox Err.Description
    Resume Exit_Write_Table_Click

    End Sub
    Private Sub Close_Form_Click()
    On Error GoTo Err_Close_Form_Click


    DoCmd.Close

    Exit_Close_Form_Click:
    Exit Sub

    Err_Close_Form_Click:
    MsgBox Err.Description
    Resume Exit_Close_Form_Click

    End Sub

  5. #5
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Definitely bound ...

  6. #6
    Join Date
    Mar 2004
    Location
    Nashville, TN
    Posts
    557
    Okay tjarvas,

    All that code does is send you to a new record. Your form objects are bound and they need to be unbound to do what you are wanting.

    Do you know how to make your form objects unbound?

    JS
    Have you ever thought about thinking on purpose?

    Jarvis Stubblefield
    Patriot Designs
    Web/Database Development and Consulting
    The-Patriot.net by Patriot Designs

  7. #7
    Join Date
    Mar 2004
    Posts
    361
    You would just remove the record source right? Maybe I should let you tell me.

  8. #8
    Join Date
    Mar 2004
    Posts
    361
    If I remove the record source then the query fails?

  9. #9
    Join Date
    Mar 2004
    Location
    Nashville, TN
    Posts
    557
    I dont know what would be needed to write the INSERT SQL query. Yes taking out the record source would do that for sure. And if you need certain text boxes to be controled by that original query then you should set their record source to that query, but not the whole form.

    JS
    Have you ever thought about thinking on purpose?

    Jarvis Stubblefield
    Patriot Designs
    Web/Database Development and Consulting
    The-Patriot.net by Patriot Designs

  10. #10
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Originally posted by JSThePatriot
    I dont know what would be needed to write the INSERT SQL query. Yes taking out the record source would do that for sure. And if you need certain text boxes to be controled by that original query then you should set their record source to that query, but not the whole form.

    JS
    Dim SQLString As String

    SQLString="INSERT INTO SomeTable ( Value1, ... ValueN ) VALUES ( 1, ..., N);"

    DoCmd.RunSQL SQLString

Posting Permissions

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