Page 1 of 2 12 LastLast
Results 1 to 15 of 25

Thread: Data Entry Form

  1. #1
    Join Date
    Mar 2004
    Posts
    361

    Unanswered: Data Entry Form

    I have a form that queries info from a table. Once the query is complete, the user can add information to other text boxes. I then have a button that updates the record with all of the user add data. Is there a way to put the focus on the first text box after the user presses the udpate table record. This would make if easier for the user to update numerious records.

    Thanks!

  2. #2
    Join Date
    Apr 2004
    Location
    metro Detroit
    Posts
    634
    at the end of your update routine add

    dcmd.gotocontrol "control_name"

  3. #3
    Join Date
    Apr 2004
    Location
    metro Detroit
    Posts
    634
    that's docmd not dcmd

  4. #4
    Join Date
    Mar 2004
    Posts
    361
    oh, good lead to my next problem. Here is the code for my two buttons

    Option Compare Database



    Private Sub Command149_Click()
    On Error GoTo Err_Command149_Click


    DoCmd.GoToRecord , , acNewRec

    Exit_Command149_Click:
    Exit Sub

    Err_Command149_Click:
    MsgBox Err.Description
    Resume Exit_Command149_Click

    End Sub
    Private Sub Command150_Click()
    On Error GoTo Err_Command150_Click


    DoCmd.Close

    Exit_Command150_Click:
    Exit Sub

    Err_Command150_Click:
    MsgBox Err.Description
    Resume Exit_Command150_Click

    End Sub

    Private Sub Exit_Button_Click()

    End Sub

    Private Sub Update_Button_Click()

    End Sub

    Unfortunatly, both the exit button (command150) and Update button (command 149) udate the table when pressed. Could you add the data needed to change focus and maybe make the exit button just close the form instead of updating it. That would be a huge help. Thanks a ton.

  5. #5
    Join Date
    Mar 2004
    Posts
    361
    that DoCmd.GoToControl "Lease_Num" idea worked well. Any idea about the exit problem?

  6. #6
    Join Date
    Dec 2003
    Location
    Dallas, TX
    Posts
    1,004
    Unfortunatly, both the exit button (command150) and Update button (command 149) udate the table when pressed. Could you add the data needed to change focus and maybe make the exit button just close the form instead of updating it. That would be a huge help. Thanks a ton.
    Hi tjarvas,
    Just checking with something here...on your ExitButton(150) you have:
    DoCmd.Close
    What are you closing exactly? Is it a form or report? I have always seem in the code what it was closing. Just kinda caught my eye, but might actually be ok. In Access when you leave a record, that is the same as saving it, in essence Updating whatever it is tied to. Do you not wish for it to be updated when you close the form or whatever?
    Now, exactly WHERE are you placing the Subs anyway. I would have the Close or Quit in the AfterUpdate event of that Update command button. When you click the Update button, it updates the record, but do you then want the form to close afterwards? If so put it in the UpdateButtons AfterUpdate Event. But either way, as far as I know, when you leave that record it is Saved...Updated.

    Bud

  7. #7
    Join Date
    Mar 2004
    Posts
    361
    Better yet here is my new code.

    Option Compare Database

    Private Sub Button10_Click()
    DoCmd.Close
    End Sub

    Private Sub Command149_Click()
    On Error GoTo Err_Command149_Click


    DoCmd.GoToRecord , , acNewRec
    DoCmd.GoToControl "Lease_Num"

    Exit_Command149_Click:
    Exit Sub

    Err_Command149_Click:
    MsgBox Err.Description
    Resume Exit_Command149_Click



    End Sub

    The exit button still seems to update the record??

  8. #8
    Join Date
    Mar 2004
    Location
    Nashville, TN
    Posts
    557
    To make the form not update after you close it you should make your form 'unbound' I dont know if you know what I mean by that but that is what you would need to do.

    You would need a form with all the same controls, but no record source. Then your update button would actually need to add the record to a table. What you are doing is just going to a new record which does the same thing the exit does since it is tied to a table or query. You will have to make your form unbound if you want to keep a user from 'saving' the record by clicking exit. In essence a record is saved as soon as you lose focus of the first field you input.

    So remove the record source from the form then make the update button use the values from the form to put into a table. May have to use an append query or something of the like. I hope someone can take what I am saying and help more because I dont know how to make an unbound form update a record.


    JS
    Have you ever thought about thinking on purpose?

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

  9. #9
    Join Date
    Mar 2004
    Posts
    361
    So I'm pretty much screwed. I'm not really adding a new record. I am just adding info to a record that is already there. I need to have the record source in the form to run the query. Unfortunatly, I need to have the query for user verification. Maybe I have hit a wall?

  10. #10
    Join Date
    Apr 2004
    Location
    metro Detroit
    Posts
    634
    You're not screwed.

    If you are only adding data to specific fields then you make the controls for those fields unbound and the rest of the controls uneditable (if that's a word).

    The other option is to make all controls unbound and set the value of specific controls in the forms current event.

    It really depends on what you're trying to accomplish. I don't understand why you would allow a user to edit data, then not save the edits when the form closes. If you could explain the purpose of the form, I may be able to help a bit more.

  11. #11
    Join Date
    Mar 2004
    Posts
    361
    Thanks for the quick reply. Let me explain the purpose of my form. This may help clear the air. Right now a user types in an acct # which brings back information into roughly 7 text boxes. Two of these text boxes may need editing because of changes that happend to those specific fields. I also have 20 or so other text boxes on the form that allows a user to add info to the specific acct#. These need to be "writen" to the table when the user presses the "update record" button. what I am afraid of is if the user makes a mistake or doesn't finish filling out the form and presses the exit button, that data is writen to the table. Unfortunatly, I am not the person who is going to be using this form. I'm trying to dumb it down a little bit. If you need any other explination please let me know. Thanks!

  12. #12
    Join Date
    Apr 2004
    Location
    metro Detroit
    Posts
    634
    Use bound controls only for the data that you do not want edited. Make those controls uneditable (look at the enabled and locked properties). Use unbound controls for the data you want updated or added and use your update routine to write it to the appropriate table(s). You can also add validation rules at the begining of your update routine to ensure that the user doesn't leave out required data or enter invalid data.

    Make sure to clear the values of your unbound controls when moving to a new record or closing the form.

  13. #13
    Join Date
    Mar 2004
    Posts
    361
    I understand the uneditable property stuff, but if I use an unbound control to allow the user to add data to the record, how will it know which field to add to when the user presses the update record button. Maybe I don't understand. Am I going to have to write this in code. Please tell me no. I have never really written this type of code.

  14. #14
    Join Date
    Apr 2004
    Location
    metro Detroit
    Posts
    634
    I thought you had an update routine behind a button already.

    If you don't want to write code you could use an update query (not as pretty - but it will get the job done)

    Create an update query using the form control names in the update to row. create a button on your form that runs the update query on the click event.

    **If you want a challange, take a look at the sql statement behind the update query and base the update routine on that (it's not as hard as it seems).

  15. #15
    Join Date
    Apr 2004
    Location
    metro Detroit
    Posts
    634
    You may want to check this out

    http://www.mvps.org/access/forms/frm0027.htm

Posting Permissions

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