Results 1 to 12 of 12
  1. #1
    projectpupil7 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2014
    Posts
    37

    Copy fields to another table.

    Hi All, first question for me so here go's.
    What i need to do is copy some fields from one table to another after updating via a pop up form. My coding skills are not excellent but would love to get this right.



    Explanation:

    Form [frmWorkItem subform] and [frmReactiveWorkPoList] are located on a tab control (Tab110, pages 0 and page1) and are linked by [ClientID] to the main form [frmReactiveTracker]. The functionig of this set up works fine.

    The process of entering data starts with [frmWorkItem subform], here i use a popup form to enter a new record and when the popup closes the new record is seen in [frmWorkItem subform]. Unfortunately there are five duplicate fields in table frmReactiveWorkPoList which can't be changed now (the result of bad normalisation and now too much work to change it).

    The duplicated fields in the newly entered record in [frmWorkItem subform] need to be copied to the respective fields in frmReactiveWorkPoList either when the popup closes or some other more efficient method.

    I would very much like to work alongside someone to achieve what i need and to help i have attached the sample stripped down database. To start open frmReactiveTracker and pick the third name from the drop down list.

    Hope you can help and thanks in advance.
    Attached Files Attached Files

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    Are you talking about adding new FIELDS to an existing table?
    or
    adding DATA to fields in another table?

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Glad you understand that this data duplication is bad design. What are the 5 duplicated fields - ClientID, Address, AssetNumber, ProfessCode, DescriptionOfWorks?

    Why do you say it is too much work to change? Is the posted db the full structure - 3 tables, 3 queries, 8 forms? Seems like a lot of work keeping them.


    The Priority combobox has error - field doesn't exist in the RecordSource.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    projectpupil7 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2014
    Posts
    37

    Thumbs up Copy fields to another table

    Quote Originally Posted by June7 View Post
    Glad you understand that this data duplication is bad design. What are the 5 duplicated fields - ClientID, Address, AssetNumber, ProfessCode, DescriptionOfWorks?

    Why do you say it is too much work to change? Is the posted db the full structure - 3 tables, 3 queries, 8 forms? Seems like a lot of work keeping them.


    The Priority combobox has error - field doesn't exist in the RecordSource.

    Thanks for your reply June7.

    Yes, the duplicated fields are:
    ClientID, Address, AssetNumber, ProfessCode, DescriptionOfWorks?

    It's too much work to change at this moment in time due to workload but IT WILL be changed. The db is part of a suite of programs to be used by a maintenance team.

    I would be interested in your comment "Seems like a lot of work keeping them" as you seem to imply that i don't need them all. By the way your perspective as a proffesional will be different from mine as a lay person. If it makes db better then i would like to know though - thanks.

    With regard to the Priority combobox - short answer is ??????. I have opened my copy of the db here at work and don't get the error. I will have a look at the zipped copy and let you know what i found. Note, Priority doesn't need to be copied over to a new table, though.

    Thanks again for your support, greatly apreciated.

  5. #5
    projectpupil7 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2014
    Posts
    37
    Quote Originally Posted by ranman256 View Post
    Are you talking about adding new FIELDS to an existing table?
    or
    adding DATA to fields in another table?
    ranman256 hi, it's only the data that i need to copy over, hth.

    Thanks. Are you really Arnie ????!!!!

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    I meant keeping the duplicate fields and figuring out how to populate them seems like a lot of work.

    Please understand I am not a professional programmer, not in the sense of contracting my services to build dbs for others. I learned on the job to meet the needs of my employer.

    So when the record is initiated in frmReactiveWorkPoList you want to pick up the 4 duplicate values (ClientID should automatically populate). Grabbing the data should not be difficult, might use module declared variables. The real trick is figuring out what event to put code in. Should it be as soon as the subform gets focus? Should it be when data is entered into OrderNo field?

    Not really understanding data relationships. Should WorkPO be related to WorkOrder instead of directly to Client?

    The red backcolor of textboxes makes it really hard to read text, almost painful.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    projectpupil7 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2014
    Posts
    37
    Hi June7, no problem. The process of entering data is started in frmWorkItem subform. After the user enters data via the popup they would close the popup form and it is at this moment (Form OnClose), (perhaps), that the record fields should be copied over.
    Yes, WorkPO is related to WorkOrder and like you i think that RED is a right PINA. IT HAS NOW BEEN CHANGED.


    The error with the Priority combobox was due to a missing field in the form's query. Must have disappeared when sending to the list.

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    So in Close button code on the popup form, one way to create WorkPO record is with INSERT SQL.

    CurrentDb.Execute "INSERT INTO tblReactiveWorkPoList(ClientID, Address, AssetNumber, ProfessCode, DescriptionOfWorks) VALUES(" & Me!ClientID & ", '" & Me!Address & "', '" & Me!AssetNumber & "', '" & Me!ProfessCode & "', '" & Me!Description & "')"

    However, not seeing the ProfessCode on the popup.

    Then will need to requery the WorkPO subform so this new record is available.
    Forms!frmReactiveTracker.frmReactiveWorkPoList.Req uery
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    projectpupil7 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2014
    Posts
    37
    This is looking good June7. However, the form doesn't close when i click the close form button.

  10. #10
    projectpupil7 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2014
    Posts
    37
    Got it now June7 (any comments)

    Private Sub cmdCloseEditWorkItemForm_Click()
    CurrentDb.Execute "INSERT INTO tblReactiveWorkPoList(ClientID, Address, AssetNumber, ProfessCode, DescriptionOfWorks) VALUES(" & Me!ClientID & ", '" & Me!ADDRESS & "', '" & Me!AssetNumber & "', '" & Me!ProfessCode & "', '" & Me!Description & "')"
    Forms!frmReactiveTracker.frmReactiveWorkPoList.Req uery
    DoCmd.Close acForm, "frmEditWorkItem"
    End Sub

  11. #11
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Works as desired? Solved?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  12. #12
    projectpupil7 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2014
    Posts
    37
    Works as desired so problem now solved. Grateful thanks June7. Hope you have a good weekend.

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

Similar Threads

  1. Replies: 2
    Last Post: 08-07-2014, 07:31 AM
  2. Replies: 8
    Last Post: 10-29-2013, 12:13 PM
  3. Replies: 1
    Last Post: 10-29-2012, 08:15 AM
  4. Copy / Paste some fields
    By isnpms in forum Access
    Replies: 2
    Last Post: 08-25-2010, 10:13 AM
  5. Copy / Paste some fields
    By isnpms in forum Import/Export Data
    Replies: 1
    Last Post: 08-25-2010, 07:48 AM

Tags for this Thread

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