How to export data to clipboard from MS Access

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rebel4ever
    New Member
    • Oct 2008
    • 4

    How to export data to clipboard from MS Access

    Ok so here's the problem. I have Table A with some fields, dont matter what fields and Table B with an ID field and a Code field. What i want to do is to use VBA to automaticaly export the XML code of table A into the Code field of table B without using external files. I couldn't find a direct way of doing this so if there isn't, maby it's possible to export the code to the clipboard and from there import it to the table.
    Any ideas?

    L.E. :
    After some more digging i've found some help on the ms site.

    With the function posted there it's possible to copy something to the clipboard. Now the problem that remains is how do i make and copy the XML code of a table to the clipboard, without using external files.
  • rebel4ever
    New Member
    • Oct 2008
    • 4

    #2
    Still needing help!!!

    Comment

    • MikeTheBike
      Recognized Expert Contributor
      • Jun 2007
      • 640

      #3
      Hi

      This is a code I came up with when the boss complained about copying employee names and addresses individualy to documents, so I put this code behide a button on the employee details form.
      Code:
      Private Sub cmdCopy_Click()
          txtClipboard = ""
          txtClipboard = UCase(Left(Forename, 1)) & LCase(Mid(Forename, 2)) & " " & UCase(Left(Surname, 1)) & LCase(Mid(Surname, 2))
          txtClipboard = txtClipboard & IIf(IsNull(Address1), "", Chr(13) & Chr(10) & Address1)
          txtClipboard = txtClipboard & IIf(IsNull(Address2), "", Chr(13) & Chr(10) & Address2)
          txtClipboard = txtClipboard & IIf(IsNull(Address3), "", Chr(13) & Chr(10) & Address3)
          txtClipboard = txtClipboard & IIf(IsNull(Address4), "", Chr(13) & Chr(10) & Address4)
          txtClipboard = txtClipboard & IIf(IsNull(PostCode), "", Chr(13) & Chr(10) & PostCode)
          Echo False
          txtClipboard.Visible = True
          txtClipboard.SetFocus
          txtClipboard.SelStart = 0
          txtClipboard.SelLength = Len(txtClipboard)
          DoCmd.RunCommand acCmdCopy
          Screen.PreviousControl.SetFocus
          txtClipboard.Visible = False
          Echo True
          
      End Sub
      The txtClipboard is a hidden control on the form which is assigned the current emplyee details. As the control has to be visible (why I don't know) for this to work Echo is turned of while it is copied to the C/Board, and the back on again after hiding the control again. There could be better ways to do this, but if it aint broke .......

      However, if, in your case, both Table A and Table B are in the same database why would you want to do it this way instead of using an Update or Append query (or something similar) ???

      HTH


      MTB

      Comment

      • rebel4ever
        New Member
        • Oct 2008
        • 4

        #4
        Thank you for the reply! However..i want to export the content of a table, in XML code format, to another table. I could use the export to XML file but i cannot do that. Like i said..access exports only to a file and i needed to find out if ( how ) i can save only the code. I thought maby access creates a blank file and fills it with the XML code and maby there was a way to make it fill a field form a table instead of the file.

        Comment

        Working...