Results 1 to 8 of 8
  1. #1
    2 Star Lounger
    Join Date
    Mar 2001
    Location
    Colorado, USA
    Posts
    144
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Problem with New Data in a combo box (Access 97)

    I'm having a problem with an application where changes are made to the data in a form (continuous form, settings for a list of beams) and then a check is performed on the unsaved data to see if it causes an inconsistency with data elsewhere in the database. The check routine clones the form's recordset and serches for the beam being used by the other data and then checks the availability setting the see if the beam is available. The problem is that the recordset clone is getting the data i n the form prior to the user's unsaved changes to it. Is there a way to get the unsaved data into the recordset?

    Thanks.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Problem with New Data in a combo box (Access 97)

    No, you can't get the data into the recordset (that would amount to saving the record, but you want to check things before saving it). But you can compare the existing records to the current, unsaved record in the form. You wouldn't want this record to be tested against itself, anyway.

  3. #3
    2 Star Lounger
    Join Date
    Mar 2001
    Location
    Colorado, USA
    Posts
    144
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Problem with New Data in a combo box (Access 97)

    Understand. Keep in mind that we are supporting code written many moons ago by folks on the east coast.

    they implemented the check by building the field name string (call it Field_Name) based on info from the other data being checked. Then they'd compare Me(Field_Name) to "No" and warn the user of a dependent data inconsistency if the comparison is true. The problem is that the form in which this code is implemented is a continuous form, showing data for several beams. If the form is made dirty by changing data in the right beam everything is OK. But, if the check is made without causing the form to be dirty, it just uses info from the first beam listed.

    How can I get the right data for the right beam every time, given this complication?

    Thanks.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Problem with New Data in a combo box (Access 97)

    I don't understand, I fear.

    When I want to check a record, I use the BeforeUpdate event of the form, and set the Cancel argument to True if the record isn't up to scratch. BeforeUpdate occurs only if a record has been changed, and it occurs just before Access tries to save the record, that is, when you are about to move to another record, or to close the form. BeforeUpdate doesn't occur if you have only looked at a record, but not changed it. So if a record is dirty, BeforeUpdate fires, causing the record to be checked. If a record is not dirty, BeforeUpdate doesnt fire, so nothing is checked (and that's OK).

  5. #5
    2 Star Lounger
    Join Date
    Mar 2001
    Location
    Colorado, USA
    Posts
    144
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Problem with New Data in a combo box (Access 97)

    That's how I'd do it too, but this form has a Save button on it that is alway enabled. When the user clicks Save, the check occurs ... whether anything has changed or not. So the check needs to occur every time the button is clicked. The problem is getting the right set of data (for the right beam) every time, whether the form is dirty or not.

    Thanks.

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Problem with New Data in a combo box (Access 97)

    Can't you use something like

    Private Sub cmdSaveRecord()
    If Me.Dirty Then
    RunCommand acCmdSaveRecord
    End If
    End Sub

    If the form is dirty, the record will be saved; this will trigger the BeforeUpdate event with the check. If the form is not dirty, nothing happens.

  7. #7
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: Problem with New Data in a combo box (Access 97)

    I take it you are working with a continuous form that is bound to a query or table of some sort. Is the new record also being added on that form as well? If so, the conventional wisdom is that new records should be added using an unbound form so you can check things before the record is ever saved. That avoids the kind of problems you are having - but it probably involves a fairly significant rewrite. This situation is one of the few where we usually choose to work with an unbound form.
    Wendell

  8. #8
    2 Star Lounger
    Join Date
    Mar 2001
    Location
    Colorado, USA
    Posts
    144
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Problem with New Data in a combo box (Access 97)

    Thanks to all for your help in this matter. Due to some circumstances that I can't go into here, I was not able to use the methods you suggest which I believe would have provided a better approach. However, I was able to step through the records on the form using a do loop that compares Me("Beam_Field_Name") to Beam_Name and do a docmd.gotorecord to go to the next record if they're not equal. Then once it gets to the right record, it can look at the other data as before.

    Thanks again for the help.

Posting Permissions

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