Results 1 to 11 of 11
  1. #1
    mercapto is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Jan 2012
    Location
    Spain
    Posts
    91

    Conflict between duplicate record command and search combo

    Hello

    I've got a form with a duplicate command and a search combobox, both created with the wizard.



    Code:
    Private Sub cmdDuplicar_Click()
    On Error GoTo Err_cmdDuplicar_Click
    
    
        DoCmd.RunCommand acCmdSelectRecord
        DoCmd.RunCommand acCmdCopy
        DoCmd.RunCommand acCmdRecordsGoToNew
        DoCmd.RunCommand acCmdSelectRecord
        DoCmd.RunCommand acCmdPaste
    
    
    Exit_cmdDuplicar_Click:
        Exit Sub
    
    Err_cmdDuplicar_Click:
        MsgBox Err.Description
        Resume Exit_cmdDuplicar_Click
        
    End Sub
    -----
    Private Sub Cuadro_combinado219_AfterUpdate()
        ' Buscar el registro que coincida con el control.
        Dim rs As Object
    
        Set rs = Me.Recordset.Clone
        rs.FindFirst "[ID_Producto] = " & Str(Nz(Me![Cuadro_combinado219], 0))
        If Not rs.EOF Then Me.Bookmark = rs.Bookmark
    End Sub
    When I press the "Duplicate" button I get "error 13 mismatch". The error points to the line in red. Also, japanese characters are shown in the combo afterwards.

    I can't understand why I get this error, because I am not using this control.

    Can anybody help me?

  2. #2
    Rod is offline Expert
    Windows 7 32bit Access 2007
    Join Date
    Jun 2011
    Location
    Metro Manila, Philippines
    Posts
    679
    Is [ID_Producto] a text variable?

  3. #3
    mercapto is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Jan 2012
    Location
    Spain
    Posts
    91
    Quote Originally Posted by Rod View Post
    Is [ID_Producto] a text variable?
    It is not.

    The combo works properly, the only problem is when I press the "duplicate" command.

    As I said, i didn't make any of this programs, they come directly from the Wizard.

  4. #4
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    It makes no sense for an error to show up in the Cuadro_combinado219_AfterUpdate code when you click on the 'copy' Command Button! That, and the fact that japanese characters are shown in the combo afterwards, would indicate that you've got corruption, here! My guess would be that the corruption involves one or more of the Controls involved. I'd start off by deleting and then re-creating the Command Button, and if that doesn't work, do the same with the Combobox.

    Linq ;0)>

  5. #5
    mercapto is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Jan 2012
    Location
    Spain
    Posts
    91
    Quote Originally Posted by Missinglinq View Post
    It makes no sense for an error to show up in the Cuadro_combinado219_AfterUpdate code when you click on the 'copy' Command Button! That, and the fact that japanese characters are shown in the combo afterwards, would indicate that you've got corruption, here! My guess would be that the corruption involves one or more of the Controls involved. I'd start off by deleting and then re-creating the Command Button, and if that doesn't work, do the same with the Combobox.

    Linq ;0)>
    thx, linq.

    As you suggested, I recreated both controls. I still had the same result. There is no more code in my form.

    Maybe we can jump this error by disabling the combo box, perhaps with an "if" that ends sub if the record is new. How would be the code?

  6. #6
    Rod is offline Expert
    Windows 7 32bit Access 2007
    Join Date
    Jun 2011
    Location
    Metro Manila, Philippines
    Posts
    679
    My next suggestion would have been very much in line with Missinglinq.

    What I believe you are trying to do is create a duplicate record. Personally I would use SQL or JET commands for copying data records.

    However Dirk Goldgar (MVP) has suggested the following:

    A very simple answer to you question is this series of VBA statements:

    RunCommand acCmdSelectRecord
    RunCommand acCmdCopy
    RunCommand acCmdPasteAppend
    Prefix this with 'DoCmd.' if you wish.

  7. #7
    mercapto is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Jan 2012
    Location
    Spain
    Posts
    91
    Quote Originally Posted by Rod View Post
    My next suggestion would have been very much in line with Missinglinq.

    What I believe you are trying to do is create a duplicate record. Personally I would use SQL or JET commands for copying data records.

    However Dirk Goldgar (MVP) has suggested the following:


    Prefix this with 'DoCmd.' if you wish.
    It worked. I get no error using this simple code.

    Thanks everyone for the answers.

  8. #8
    mercapto is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Jan 2012
    Location
    Spain
    Posts
    91
    Ok, It's not working again...

    I went to the combo sql config and sorted the records by name, and then the error appeared again.

    I can confirm that the error is not happening when the combo query is default. The error does not show up when the list is unsorted.

    I guess Rod's code did not solve the problem, it worked just because after all the trials I didn't finish the combo properly.

  9. #9
    Rod is offline Expert
    Windows 7 32bit Access 2007
    Join Date
    Jun 2011
    Location
    Metro Manila, Philippines
    Posts
    679
    I shall try to duplicate what I think you are doing and see if I can replicate the error.

  10. #10
    mercapto is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Jan 2012
    Location
    Spain
    Posts
    91
    What I finally did is to give a value (in the list) to the combo at the end of the code.

    It seems that somehow those Japanese characters are updated in the combobox and the error comes because it is not an element of the list. So I take it to other element just before the error shows up.

    It could be done better, I know... Not solved.

  11. #11
    Rod is offline Expert
    Windows 7 32bit Access 2007
    Join Date
    Jun 2011
    Location
    Metro Manila, Philippines
    Posts
    679
    mercapto,

    I have been unable to duplicate your error. My code runs error free but unfortunately does not produce the desired result. I get a new record appended to the table but it is empty apart from the autonumber primary key! Is your code copying all the attribute values?

    However it seems that RunCommand acCmdPaste and RunCommand acCmdPasteAppend both trigger the combo box After Update event, twice! This explains the run time error you were getting.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 7
    Last Post: 08-08-2012, 03:28 PM
  2. How to search for duplicate combinations
    By EvanRosenlieb in forum Access
    Replies: 5
    Last Post: 04-17-2012, 02:56 PM
  3. Record Conflict Check
    By theilercabin in forum Forms
    Replies: 3
    Last Post: 10-11-2011, 01:55 PM
  4. 2 combo boxes - Conflict
    By JimS in forum Forms
    Replies: 3
    Last Post: 10-13-2009, 03:49 PM
  5. Duplicate command button
    By brettg in forum Database Design
    Replies: 1
    Last Post: 08-04-2008, 04:16 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums