Results 1 to 14 of 14
  1. #1
    3 Star Lounger
    Join Date
    Mar 2001
    Location
    Frederick, Maryland, USA
    Posts
    296
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Adding a New Record (A2K SR1)

    The forms in my database system have a 'common user interface' which consists of the same command buttons across the top of each form. The first button in the row is a New Record button. What is the simplest way of ensuring that a user presses the New Record button BEFORE he/she erroneously starts entering a new record over existing data that displays when the form is initially displayed?

  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Adding a New Record (A2K SR1)

    In the on current or on open event from the form, set the focus to the command button.

    An other possibility would be to set the Allow Edits of the form to No and with another button, set the Allow Edits to Yes when they want to make changes to the record. In the AfterUpdate or in the On current event of the form, reset the Allow editions to No
    Francois

  3. #3
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Adding a New Record (A2K SR1)

    Another way of dealing with this is to open the form with an empty recordset and allow the user to work with only a single record at a time. You would have to create controls that let the user specify the record they want to see, but the form will load faster and there is no risk of overwriting an existing record or even editing the wrong record by accident. I never let users browse records in applications I design. The only time they see multiple records is in a subform.
    Charlotte

  4. #4
    2 Star Lounger
    Join Date
    Apr 2001
    Location
    Wellington, New Zealand
    Posts
    173
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Adding a New Record (A2K SR1)

    I some-times use the forms allowedits property.

    By default, this property I set to false (which prevents users from editing any of the records).

    When the 'new record' button is pressed, I then set the property to true to allow users to edit the record (and I move to the new record).

    I then use the afterupdate property of the record to set the allowedits property back to false to prevent them from editing another record by accident.

    Using this method also means that I have a button these forms that is 'Edit' which when pressed, performs roughly the same function, but allows the user to edit data in the current record (sometimes I perform checks to make sure that are allowed to edit that particular record etc etc).

    Hope this gives you another idea.

    J

  5. #5
    2 Star Lounger
    Join Date
    Apr 2001
    Location
    Wellington, New Zealand
    Posts
    173
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Adding a New Record (A2K SR1)

    Here is something that sort of does the trick?

    Although I put you wrong the first time. It is the AllowAdditions property (silly me) for adding records, and the AllowEdits property for editing records.

    Cheers
    Attached Files Attached Files

  6. #6
    3 Star Lounger
    Join Date
    Mar 2001
    Location
    Frederick, Maryland, USA
    Posts
    296
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Adding a New Record (A2K SR1)

    Charlotte,

    Can you please provide guidance on how to open the form with an empty recordset? I searched previous posts on the subject (77514, 77417, 85364), but don't understand how to actually get new data into my table or search/browse/delete records when I use the following as my form recordsource:

    SELECT * FROM tblMYTABLE WHERE 1=2

    Thanks for your patience and help.

  7. #7
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Loading an Empty Recordset (A2K SR1)

    That approach will open the form with an empty recordset while still allowing all the controls to be properly bound to the fields. Then you need one or more controls that serve as "finder" controls. I usually use a textbox and a combobox when the potential recordset is large. The textbox allows the user to type in one or more characters, such as a partial client name or account number, etc., that will allow you to filter the list down to a manageable number. In the AfterUpdate event of the textbox, you create the SQL rowsource for the combobox. <pre>"SELECT CustomerID, CustomerName FROM tblCustomers WHERE CustomerName Like '" _
    & Me.txtFinder & "'"</pre>

    The user selects the actual record from the combobox. In the AfterUpdate of the combobox, you change the recordsource of the form to a Select statement that filters for the specific record chosen in the combobox.<pre>strSQL = "SELECT * FROM MyTable WHERE CustomerID = " & Me.cboFinder
    Me.Recordsource = strSQL
    </pre>

    Does that explain it adequately?

    BTW, there is an alternative to the last part. You could also have a saved query that takes the combobox value as its criteria and you could simply set the recordsource to that query instead of building the SQL in code.
    Charlotte

  8. #8
    3 Star Lounger
    Join Date
    Mar 2001
    Location
    Frederick, Maryland, USA
    Posts
    296
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Loading an Empty Recordset (A2K SR1)

    One of the buttons of my common user interface is a Find Record button that brings up the typical Search dialog box. Using the empty recordset approach, can I open the form empty, then use the Find Record function to retrieve the desired record?

  9. #9
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Adding a New Record (A2K SR1)

    Hi Charlotte

    I like the concept of working with empty record sets.

    I established my lookup text and combo boxes as suggested. My initial record source is select * from tblBPermit where 1=2, when form is opened I get blank form and can

  10. #10
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Loading an Empty Recordset (A2K SR1)

    The simple answer is no. Find is only going to apply to the loaded recordset, and you don't have any records in it. You have to set the recordsource of the form based on whatever selection is made from your "finder" controls.
    Charlotte

  11. #11
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Adding a New Record (A2K SR1)

    You should see the controls but without anything in them. If you don't see them, it may be the result of your color and border settings. For instance, if your backstyle is transparent and your border is light gray and flat, you may not be able to see the controls unless they have data in them. You could try setting the backstyle to normal and see if that makes a difference or set the borders to sunken.

    My users work with one record at a time, period. I give them a button to click for a new record which results in different handling from an edit situation. I set the cycle property to current record so they can't tab to a new record, and once the record is saved, they have to click new record again to add another. Since they only work with one record at a time, I disable the navigation buttons, so they don't see the numbers which are meaningless in this context anyhow.
    Charlotte

  12. #12
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Adding a New Record (A2K SR1)

    Hi Charlotte

    My

  13. #13
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Adding a New Record (A2K SR1)

    <blockquote><hr>My
    Charlotte

  14. #14
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Adding a New Record (A2K SR1)

    Hi Charlotte

    Perfect!

    Thanks for the clinic, keep up the good work.

    John

Posting Permissions

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