Topics Search

Best way to display VBA query results?

Best way to display VBA query results?
Views: 88
What is the best way to display the results from a VBA query in Access (97)?

User fires of query with a button click. I just want to open up a table view of the results but since I am new to Access dev I am not sure how to do this.

Dim productName As String
Dim strSql As String
Dim dbs As Database
Set dbs = CurrentDb()
Dim rs As Recordset

productName = "ADSL"

strSql = "SELECT [Information].* From [Information] WHERE [Information].Product = " & Chr(34) & productName & Chr(34) & ";"

Set rs = dbs.OpenRecordset(strSql, dbOpenSnapshot)

How do I open the RecordSet up in a table (view)?
Sponsored Links:

Similar posts...


VBA Code to show query results

VBA Code to show query results Icon
I have another issue. I'm still working on my code for over 2 weeks now and I've made great strides, but I have one final hurdle.

I am able to list results of my query in a VBA drafted email, however I cannot put any criteria on it to limit the results. I have a form that is tied to my VBA code and when I click it, it will draft the email and list details on the form. The last item I need to list are items contained in a subform.

Currently I get results, however I get all results for all records and not the current record. Normally in the query I would input a simple line like: [Forms]![Supply Requests]![Request ID] to return the items only for the specific record. However when I do that on the query, the VBA code crashes...

Execute SQL statement and display results on a form using VBA

Execute SQL statement and display results on a form using VBA Icon
I have a form which builds and executes SQL statements based on the users inputs on some checkbox and textbox controls on a form.

Currently I then take the formed SQL, create a temporary query and then open the newly created query read only. The result is the query output in the normal Access datasheet style view.

What I would like to do is form my SQL as I am currently doing, but rather than create and open a query - execute the SQL and display the results into / onto a form. One other requirementis I need the user to be able to copy the entire results to clipboard so the data can be pasted into Excel or Word for example.

Is this possible or have I got to stick with the query datasheet view?

VBA Show query in a form/subform

VBA Show query in a form/subform Icon
I am have great difficulty with getting a subform to show data.

How I Ideally want this to work Is that I have one form/subform that I can then pass the results for query’s to via VBA every time buttons on some of my other forms are pressed.


Form 1 button click
opens the form/subform wIth the query
Select * from tbltest

Form 2 button click
opens the same form/subform but has the results from
Select * from tblretest

Is there a way to do thIs so that I can have one form/subform and just pass query results for It to display.

I really don’t want to have to make a form for each Individual query

Display Query Results on a Form

Display Query Results on a Form Icon
I have a query that finds birthdays in the current or upcoming month. I would just like to display the results of the query on a form, I was thinking in a textbox, and have the textbox refresh the query everytime the form is opened.

The only piece I am having trouble with is linking the textbox to the query. I tried just setting the control source to the query, but I get a ?Name? error.

Pivot/Array results

Pivot/Array results Icon
I need to display my results from a query of multiple records into 1 record. I can't figure out the query that will give me the results I need below,

See example below:

display query results in a form

display query results in a form Icon
This is probably a simple questions, but I have a query that I am hoping to use to either open a form to the first record of the query, or display the results of a query on a form (or report) and allow the user to click on a result and open another from. Make sense?

How to Build and export a crosstab query in VBA?

How to Build and export a crosstab query in VBA? Icon
What I'm trying to do is create a crosstab query (based on a temp table) in VBA, then export it to Excel. The temp table is built off a form where the user enters a parameter(s) in a textbox(es).

I created the crosstab query using the wizard and copied the code into my VBA (button click), but it's not an action query, so DoCmd.RunSQL won't work.

Then I tried:

1) Dim rst as Recordset
2) Set rst = CurrentDb.OpenRecordset(strSQL)
But where do I go from there?

I guess, really, I don't need to put it into a table if I'm just going to export it to Excel anyway, and it need not be a crosstab query: How do I create a SQL SELECT statement in VBA and display the results?

Query To Form

Query To Form Icon
I have a query that runs fine. It pops up and gives me the results I want, however I want those results to be displayed on a SubForm.

Im using Access 2003. It shows the DataView. How do I get the Results from the Query into the SubForm?

Please help, been stumped for days.

PS. I did try changing the (record source) To the Angle Query for the Form. But still it does not Display the Data in the form

Exporting the results of a query to Excel

Exporting the results of a query to Excel Icon
I have created a query in Access 2007 which pulls data from the table for a certain time period. The query contains lookups so the results of the query display table values rather than ID's.

However, when I export the results of the query to Excel, the ID's not the values are displayed. How can I get access to export the exact results of the query.

Tally records in VBA

Tally records in VBA Icon
currently I have a listbox which displays some results using an SQL query in the row source. In the list box I display records from a parent and child table. Therefor I'm getting duplicate information from the parent. (picture)

This is what I want for display purposes. But I want to be able to create a tally of all the students that came. In the example attached, You can see that for the first record, there are actually 3 parent records displayed each with 80 kids. but truely there was 80 in total. not 240.
I was hoping to run some VB code to tally the results in my list box, but adding the values in the column wont give me the results I want. Any Ideas? should I use a hidden list box with ONLY the parent records
Sponsored Links: