Results 1 to 10 of 10
  1. #1
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Toronto Canada
    Posts
    920
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Duplicating a Record Problem (Access 2000 (9.0.6926 SP3))

    Somewhere in the not too distant past I came across this marvellous piece of code, and my apologies to the author for losing his/her name, that worked perfectly until just recently. The concept is that you click on the command button to duplicate the current record and it sends up the message:

    Are You Absolutely Sure You Want to Duplicate This Model Home

    You click on yes and it creates the record and gives you instructional information on how to handle the newly duplicated record. When I click on the command button, I do get the
    Attached Files Attached Files
    Cheers,
    Andy

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

    Re: Duplicating a Record Problem (Access 2000 (9.0.6926 SP3))

    While code execution is paused, you can't view or set references.

    When the error occurs, and you are taken to the Visual Basic Editor with .Fields(X%) = fld(X%) highlighted, activate the Immediate window (Ctrl+G).
    Type ? .Fields(X%).Name and press Enter. This will display the name of the field about to be updated.
    Next, type ? fld(X%) and press Enter. This will display value about to be assigned.
    Does this tell you anything?

  3. #3
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Toronto Canada
    Posts
    920
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Duplicating a Record Problem (Access 2000 (9.0.6926 SP3))

    Hans, thanks as always for the quick reply. At least I can stop beating my brains out with respect to references.
    I followed your instructions and it revealed that the field where it hung up was a legitimate calculated field and the contents displayed were correct. Unfortunately this doesn't tell me a whole lot but it has taught me something new. I'm a total newbie with respect to using debug features. I'd appreciate any further suggestions.

    Andy
    Cheers,
    Andy

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

    Re: Duplicating a Record Problem (Access 2000 (9.0.6926 SP3))

    What do you mean by "a legitimate calculated field"? The message you're getting suggests that your "calculation" is going awry because you can't divide by zero. Where does the calculation come into this?
    Charlotte

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

    Re: Duplicating a Record Problem (Access 2000 (9.0.6926 SP3))

    Since you mention a calculated field, I assume that the record source of the form is a query. Calculated fields should not be copied. The code you are using has a variable exclude$ you can use for this purpose. Set this variable to a comma-delimited list of fields that should *not* be duplicated; this must be done after the line where the variable is declared (Dim fld(200), ..., exclude$) and before you start manipulating the records (With RecordsetClone). Something like

    exclude$ = "Fieldname1,Fieldname2"

    where Fieldname1 and Fieldname2 are names of the fields that should not be duplicated.

  6. #6
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Toronto Canada
    Posts
    920
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Duplicating a Record Problem (Access 2000 (9.0.6926 SP3))

    Charlotte,
    I mentioned the fact that it was a calculated field that was being flagged and not just a data field. The calculation is working OK. I mentioned it because it was the field that came up in the Debug analysis and in past posts I've been known to leave out crucial information.

    Andy
    Cheers,
    Andy

  7. #7
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Toronto Canada
    Posts
    920
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Duplicating a Record Problem (Access 2000 (9.0.6926 SP3))

    Hans,

    Unfortunately this duplication did work in the past with the calculated fields. I will try to try and apply your suggested code in the correct places and will get back to you later with the, hopefully, positive results.

    Andy
    Cheers,
    Andy

  8. #8
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Toronto Canada
    Posts
    920
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Duplicating a Record Problem (Access 2000 (9.0.6926 SP3))

    Hans,

    Once more have you come through with the sagest of advice. Using the exclude$ worked perfectly. What makes very curious, however, is how did this routine manage to work for a number of months with no apparent problems. It just mindles my boggle. Thanks again,

    Andy
    Cheers,
    Andy

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

    Re: Duplicating a Record Problem (Access 2000 (9.0.6926 SP3))

    Any chance that you changed the Record Source of the form in the meantime? I can't believe that the routine would have worked correctly on a calculated field.

  10. #10
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Toronto Canada
    Posts
    920
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Duplicating a Record Problem (Access 2000 (9.0.6926 SP3))

    Hans,
    There has been no change whatsoever in record source. It's been exactly the same for well over a year. Now, this is something that I didn't want to mention when I was working on this problem this morning, but at least on three occasions, when I went back into the form, and this was before I added your changes, the duplication routine would work on 1 record and then crash on any ensuing records. It was way too random to mention. Now it works 100% with your changes, so I'm letting a sleeping module lie. Again, appreciate your attention and help,

    Andy
    Cheers,
    Andy

Posting Permissions

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