Results 1 to 4 of 4
  1. #1
    WAVP375 is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2015
    Location
    Dayton Ohio
    Posts
    171

    Cannot copy a table in VBA

    I am attempting to copy a table at year end for future processing.
    The two tables involved are identical straight forward tables, TblVolunteers and TblLastYear.
    When I execute the command, DoCmd.CopyObject, "TblVolunteers", acTable, "TblLastYear"
    I get a message 'The name you entered already exists for another object of the same type in this database.
    Do you wish to replace the existing table "TblVolunteers? Yes/No
    I'm not trying to replace "tblVolunteers" , just copy it. If I select 'Yes' I then get another message,
    Runtime error 2387
    You cant delete table "TblVolunteers" it is participating in one or more relationships.
    Once again I am not attempting to delete the table.

    What am I missing?



    Thanks

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    Odd.
    try a make table query.
    tho you don't normally destroy existing tables....you make a copy.

  3. #3
    WAVP375 is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2015
    Location
    Dayton Ohio
    Posts
    171
    Quote Originally Posted by ranman256 View Post
    Odd.
    try a make table query.
    tho you don't normally destroy existing tables....you make a copy.

    That works well. I was just trying to eliminate 1 query.

    Not my day however.
    Attempting to join a unmatch query with three fields from another table,
    QmatTblLastYearToTblVolunteers and TblVolEd.
    All fields in the query and three fields in the table are included in the query design frame.
    All seems normal but the result is blank.
    I'm not much on the SQL but from what I see it looks fine also.

    SELECT QmatTblLastYearToTblVolunteers.Badge, QmatTblLastYearToTblVolunteers.FirstName, QmatTblLastYearToTblVolunteers.LastName, QmatTblLastYearToTblVolunteers.Title, QmatTblLastYearToTblVolunteers.StatusCode, QmatTblLastYearToTblVolunteers.TypeCode, QmatTblLastYearToTblVolunteers.KindCode, QmatTblLastYearToTblVolunteers.Street1, QmatTblLastYearToTblVolunteers.Street2, QmatTblLastYearToTblVolunteers.City, QmatTblLastYearToTblVolunteers.State, QmatTblLastYearToTblVolunteers.Zip, QmatTblLastYearToTblVolunteers.HomePhone, QmatTblLastYearToTblVolunteers.CellPhone, QmatTblLastYearToTblVolunteers.Email, QmatTblLastYearToTblVolunteers.LifeHours, QmatTblLastYearToTblVolunteers.YTDHours, QmatTblLastYearToTblVolunteers.StartDate, QmatTblLastYearToTblVolunteers.StopDate, QmatTblLastYearToTblVolunteers.DateOfBirth, TblVolEd.Course, TblVolEd.[Completion Date], TblVolEd.Time
    FROM QmatTblLastYearToTblVolunteers INNER JOIN TblVolEd ON QmatTblLastYearToTblVolunteers.[Badge] = TblVolEd.[Badge Nbr];

    Any thoughts.

  4. #4
    Micron is online now Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    I'm not trying to replace "tblVolunteers"
    I'd say you are. The first name is the copy name, the next name is the source name, so you're saying "copy TblLastYear as TblVolunteers". As for the latest question, there's no way I could figure that out just by reading a novel of sql. Usually when queries don't perform as expected, I copy the original and remove fields/tables from the copy until records appear. Then by the process of inclusion, attempt to narrow down the problem until it breaks again. It could be a join, criteria, missing table required for the search - many things. 2 suggestions I'd make
    1) use code tags with indentation for more than a few lines of code or sql. Makes it easier to read and avoids the automatic insertion of spaces here at 50 characters of unbroken text

    2) maybe research table aliasing so you can shorten your sql. Would help you and others who have to read it. It would look something like
    Code:
    SELECT T1.Badge, T1.FirstName, T1.LastName, T1.Title, T1.StatusCode, T1.TypeCode, T1.KindCode, T1.Street1, T1.Street2, T1.City, T1.State, T1.Zip, T1.HomePhone, 
    T1.CellPhone, T1.Email, T1.LifeHours, T1.YTDHours, T1.StartDate, T1.StopDate, T1.DateOfBirth, TblVolEd.Course, TblVolEd.[Completion Date], TblVolEd.Time
    FROM T1 AS QmatTblLastYearToTblVolunteers INNER JOIN TblVolEd ON T1.[Badge] = TblVolEd.[Badge Nbr];
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. Replies: 10
    Last Post: 08-31-2018, 08:04 AM
  2. Replies: 1
    Last Post: 08-29-2018, 10:26 AM
  3. Replies: 18
    Last Post: 08-09-2018, 06:45 AM
  4. Replies: 8
    Last Post: 06-07-2017, 01:27 PM
  5. Replies: 1
    Last Post: 09-03-2014, 10:48 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