Modules & VBA :: Copy Outcome Of Query Results To Clipboard
Jul 8, 2013
I'm trying to copy the outcome of a query to the clipboard. as follows
DoCmd.OpenQuery "changeboard query", acViewNormal, acEdit
DoCmd.SelectObject acQuery, "CHANGEBOARD QUERY"
RunCommand acCmdCopy
DoCmd.Close acQuery, "Changeboard query", acSaveNo
It doesn't work because in the open query there is nothing selected.
If I select the lines by hand the copy command works fine.
However I can't find the command in VBA to select all the lines in the query.
View Replies
ADVERTISEMENT
May 19, 2014
I found the following code to copy the results of a query to the clipboard.
Code:
DoCmd.OpenQuery "DataLoadTemp_qry", acViewNormal, acEdit
DoCmd.SelectObject acQuery, "DataLoadTemp_qry"
DoCmd.RunCommand acCmdSelectAllRecords
RunCommand acCmdCopy
DoCmd.Close acQuery, "DataLoadTemp_qry", acSaveNo
It works great, except that it is also copying the column headings. Is there any way to copy only the results without the headings?
I'm copying this data to the clipboard because I want to be able to paste it in a program called DataLoad which will load this data into one of our company's legacy systems.
View 1 Replies
View Related
May 28, 2015
I am copying a range from excel (multiple rows) and paste it directly to access table using:
Code : DoCmd.RunCommand acCmdPasteAppend
Sometimes it does not work and I need to use paste special as text.
Is there any way to paste special as text using VBA ?
View 3 Replies
View Related
May 30, 2014
I am using some vba code (see below) to put some data into the clipboard for pasting elsewhere.But it seems to fail sometimes, I think it fails when the data is too long.Is there a maximum?
The code below fails on the stmt, "DoCmd.RunCommand acCmdCopy" No specific error msg, just the dreaded "Microsoft Access Must Close...."It seems to happen when the length of the textbox is over 1000 characters.I tried inserting some DoEvents statements, but it made no difference.
Private Sub btnCopy_Click()
Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset("tblLogs", dbOpenDynaset, dbSeeChanges)
If rst.RecordCount = 0 Then
rst.Close
Set rst = Nothing
[code]....
View 3 Replies
View Related
Aug 29, 2013
Is there a way to prevent the col headers from copied to the clipboard when copying a datasheet? When I paste to excel i don't want the headers - ?
View 2 Replies
View Related
Apr 15, 2014
I am trying to copy a caption from a form to the clipboard so that I can later paste it into another application.
The code I have found via a search on this website 1) Clears the clipboard and then 2) copies the caption from a nominated field. 2) doesn't work as I sure I have the statements wrong.
Call EmptyClipboard
Me.B7_DB_GCUH.Caption
DoCmd.RunCommand acCmdCopy
View 1 Replies
View Related
Aug 7, 2013
I am looking to create a button in access that will allow a field to be copied the the clipboard based on information in a query and then separated by a ";" and then can be pasted in another program.
I have created a database to keep track of membership. In the Member Personal Info Table I have collected their email address's and then created a query "Active Member Personal Info" for Active Members to have their name and Email displayed in the query. Now I am trying to take the 140 members email address and paste it in a gmail BCC line by clicking paste rather than doing each individual record and then copying and pasting.
View 1 Replies
View Related
Mar 10, 2014
I'm after a macro or something to allow me to map a button on a form so that when it's pressed it copy's a certain field to the clipboard?
View 1 Replies
View Related
Sep 9, 2013
I have a form with two Text box fields "Username" & "Password"
I want to create a copy button next to each field that will copy the contents to the clipboard.
The password field has the code:
Code:
Private Sub Command228_Click()
Me!Password.SetFocus
DoCmd.RunCommand acCmdCopy
End Sub
The username field has the code:
Code:
Private Sub Command229_Click()
Me!Username.SetFocus
DoCmd.RunCommand acCmdCopy
End Sub
The Username copy button for some reason gives me the following error:
Run-time error '438': Object doesn't support this property or method
Why it doesn't like this field?
View 4 Replies
View Related
Oct 18, 2014
I have a query that is based on Property & tenants. It runs a report that gives me all the property listed with the tenants & other info for the property's. Sometimes the tenant moves out & the property is Vacant, so i have a Vacant flag in the property table.
But when i run the query it prints out the last tenant. Can i pick up the vacant flag & change the tenant name to Vacant on the report? As i don't want to delete the tenant from the tenant table.
View 3 Replies
View Related
May 18, 2014
I would like to place an image file located at e.g. "C:MyImagesimage.png" into the clipboard. I have not been able to figure out how to do this. I have been able to place Text into the Clipboard using the DataObject late binding sub below.
Code:
Public Sub PutInClipBoard(strString As String)
Const DATAOBJECT_BINDING As String = "new:{1C3B4210-F441-11CE-B9EA-00AA006B1A69}"
With CreateObject(DATAOBJECT_BINDING)
.SetText strString
.PutInClipBoard
End With
End Sub
View 2 Replies
View Related
Jun 24, 2014
I would like to be able to join 2 text boxes and then copy them to clipboard. My initial fumbling has had me to joing the 2 text boxes as a string and then set that string as the value of another hidden text box and then copy that text box.
strOut = Me.Title & Me.Description
Me.CopyTxt.Visible = True
Me.CopyTxt.Value = strOut
Me.CopyTxt.SetFocus
DoCmd.RunCommand acCmdCopy
Me.Title.SetFocus
Me.CopyTxt.Visible = False
This does work but I would like to format the output if possible to remove the element identifiers? The string copies out as below.
Title Information<div>Description Information</div>
Is it possible to remove the <div> and any other elements that may appear either using my method or another way. Not sure if they are appearing as the Title box is plain text and the description is Rich?
View 4 Replies
View Related
Dec 20, 2013
I have a excel object I have opened, and want to copy a query into a named range on the workbook.
heres the start have made
Sub openExcel()
'WillR - opens the specified Spreadsheet
Dim xlApp As Excel.Application
Dim xlWB As Excel.Workbook
Set xlApp = New Excel.Application
With xlApp
[Code]...
View 2 Replies
View Related
Mar 7, 2014
I have spent the day using Access 2010 and attempting to move information from a parameterized query into specific cells in an excel template. It runs smoothly until I attempt to reference the query at which point I run into th error "Too few parameters. Expected 1." Currently my reference code looks like this:
Dim T As Recordset
Set T = CurrentDb.OpenRecordset("SELECT [8D Data].ID, [8D Data].[Customer Closed], [8D Data].[Days Open], " & _
"[8D Data].[Open Date] , [8D Data].[QN #], [8D Data].[Last Report Date], " & _
"Leaders.[Leader Name] , Leaders.[Leader Title], Leaders.[Leader Phone #], " & _
"Leaders.[Leader Email], [8D Data].[Part Description], [8D Data].[Customer P/N], " & _
"[8D Data].Customer , [8D Data].[Vehicle Year], [8D Data].[Problem Description]" & _
"FROM [8D Data] INNER JOIN Leaders ON ([8D Data].Lead = Leaders.ID)" & _
"WHERE ((([8D Data].ID)=[Enter QCR #]));")
View 4 Replies
View Related
Jan 20, 2014
I have a query which returns a list of reports I have created this session.
I want a button that when I click it runs the query and then stores the results into a variable.
I looked online and found a pretty good connection code and loop code to get the data but I'm having a hard time getting it to store into a variable.
What I want to do next is using code print the reports that were listed in the query.
That Means I need to be able to take that variable and pop the information off it, storing it into another variable (or if i can use an array just use that) and use that to concatenate into a command to print that report.
I am having problems with the syntax of this though. I think I'm just missing some key elements.
View 3 Replies
View Related
Mar 22, 2015
I was beginning to think I had got the hang of creating queries on the fly in VBA. After several hours I have just learned that docmd.runSQL does not work for simple SELECT statements. I'm not going to worry about why that would be. I'm sure there's a jolly good reason.
So... I am able to dynamically create the SQL string for the SELECT statement that I need.
How do I run it? It just needs to return results as a datasheet so I can see them. I'm running Access 2013. I've been searching on this subject for quite a while and found many references to DAO, ADO, ADODAOD, YODELAEYYOUDELAYIO! and other things I don't yet understand ...
View 8 Replies
View Related
Jan 29, 2015
I have a query that randomly selects records from my table:
SELECT TOP 6 *
FROM SM_Import
ORDER BY rnd(INT(NOW*id)-NOW*id);
I would like to loop through those results, and create emails
I can get one email formed (displayed) with the code below but don't know how to get both working together to display the (6) emails:
Private Sub Command3_Click()
Dim ol As Object
Dim CaSubject As String
[Code].....
View 4 Replies
View Related
Sep 24, 2013
My company is finally using my accounts package (alongside our original package until we can be certain there are no bugs).
Anyway just adding nice to have features at the moment.
I've got a form that has 5 combo boxes where the user can select 5 customers. Then a button so they can graph the amount of money generated by each customer and compare them.
I've just made a query to return the top 5 highest grossing customers.
What I what to do now it feed the query results into the combobox values when I press a new button on my form.
How do I go about this?
View 1 Replies
View Related
May 28, 2014
I have an Access 2010 application that talks to SQL Server. Part of the application creates tables on the SQl Server and inserts data to it (I know SQL Server has its on data inport/export wizard and bulk insert capabilities but for reasons outside of my control it needs to be done from Access). So I have a connection to the SQl Server and i have VBA that happily executs SQL statements on the SQl Server. The problem is I want to return a recordset from the result of a SQL query issued to the SQL Server. The idea being to check for the presence of tables already created, and if so, append to the already existing table, otherwise if it does not exist, create it and insert data to it.Ive tried the following code but it seems no recordset is being returned:
Set objConnection = New ADODB.Connection
objConnection.Open "DRIVER={SQL Server};SERVER=10.200.3.14;trusted_connection=yes; DATABASE=" & Me.Combo54
strSQL = "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' AND TABLE_NAME = '" & Me.Combo54 & "'"
strSQL = "USE " & Me.Combo54 & " " & strSQL
Set Rst = cmd.Execute("USE " & Me.Combo54 & " " & strSQL)
View 1 Replies
View Related
Jun 28, 2015
I basically want to Loop through a query (or if not possible trough a table) and show the results in my form. For each record in the table I am doing additional checks when loading the form and showing that result accordingly. I do not want to do these checks in additional queries - I think it is more efficient doing it in the form directly. Here is the code I have:
Dim dbsSR As DAO.Database
Dim rstValQry As DAO.Recordset
Set dbsSR = CurrentDb
Set rstValQry = dbsSR.OpenRecordset("qry_val_tbl_ind_rec-rev_import")
With rstValQry
While (Not .EOF)
[Code] ....
The Loop seems to work because in debug it is going through it 3 times (the number of records I have in the query), but the result is always the same - it seems the above code is not checking / refreshing based on the individual query records.
View 14 Replies
View Related
Sep 30, 2013
Is it possible to have a macro button to pass query results to a listbox? I have a database where I have some fields with dates. What I need to do is to show a list of all cases that have a start date (and also the end date). So I will have 2 buttons, one that says "show started cases" and second one "show closed cases". If I press the first button, it will run a query and show only those cases that have a date filled in the started case field. I made a button that shows the results in a report, but I would like to have it show up in a listbox so I can double click it and go straight to the case.
View 14 Replies
View Related
Jul 8, 2014
I have a form with a list of names. When a specific name is selected from the list, a button is clicked and a query is run with the specific name as the criteria/filter.
I've written code to export these same query results to an Excel sheet, and I want the Excel file name saved with the name selected in the form.
Below is the code that I've written that doesn't work.
Code:
Dim strFileName As String
strFileName = SelectedItems(Me.lstName)
DoCmd.OutputTo acOutputQuery, "qryFocal_Sheet", acFormatXLS, "C:JRSWorkEquityFY2015" & strFileName & ".xls"
View 7 Replies
View Related
Oct 16, 2014
I have successfully used VBA to populate select query results into an excel worksheet on open, for a co-worker. Now I am trying to populate the records from an append query to the bottom of those results, which are now in a table on an excel spreadsheet, Contractor EIF. I am trying to make this work because my co-worker modifies the results in the table, deleting rows, adding fill color etc. and as new projects begin he would like those added to the projects already in the table (without rewriting the entire table).
Private Sub Window_Open()
Dim strDB As String
Dim strMyPath As String
Dim strDBName As String
[code]....
View 2 Replies
View Related
May 24, 2014
I have created some code to get the records of a query and it puts them in the body of the email but it doesn't format it well for example the email looks like
James | halliwell | 31
Leanne | smith |27
Alexis | smith |8
I would like it to be in a table is this possible,
Code:
Public Function SendEmail()
Dim MyDB As DAO.Database
Dim rst As DAO.Recordset
Set MyDB = CurrentDb
[Code] .....
View 3 Replies
View Related
Jun 27, 2013
I am trying to loop through a query results to extract email addresses from a query result.
I have the following code
NameCriteria = Forms![MainMenu]![tbl_Course_Details]![Course_Name].Value
DateCriteria = Forms![MainMenu]![tbl_Course_Details]![Course Date].Value
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim sqlStr As String
[Code] .....
If i run this in access as a query then it returns results but when i run in there then it says no current Record and i cant work out why?
Someone on another post said that sql uses US date format so i tried converting to us date and still no results?
View 6 Replies
View Related
Dec 4, 2014
We have a button running a SQL query via VBA, how can I make it so the results doesn't show up in a table/preview?Also, I know it's for the SQL forum but how can I make a text box to show the results of a query to display it on screen?
View 8 Replies
View Related