473,320 Members | 2,027 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Referencing listbox value in export code

Hello,

I have a listbox populated with a series of queries. I am trying to write code so the user selects the query from the list and clicks and export command button.
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdExport_Click()
  2. Dim strQuerySelect As String
  3. Dim lstQueryBox As ListBox
  4.  
  5. strQuerySelect = lstQueryList.Value
  6.  
  7. DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, strQuerySelect, "C:\Documents and Settings\RCEA Intern\Desktop\February.xlsx"
  8. End Sub
Feb 9 '12 #1
1 1652
ADezii
8,834 Expert 8TB
You can accomplish this in two Lines of Code, namely:
Expand|Select|Wrap|Line Numbers
  1. If IsNull(Me![lstQueryList]) Then Exit Sub
  2.  
  3. DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, Me![lstQueryList], _
  4.                           "C:\Documents and Settings\RCEA Intern\Desktop\February.xlsx"
Feb 10 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Wishing I was skiing mom | last post by:
Newbie to VB .NET. My solution contains an item maintenance screen, one of the fields on the screen is an item status, this field is defined as a listbox. The listbox item property contains a...
2
by: jpalmerx | last post by:
Hi, I have a form in Access with a listbox containing some choices. There is a "Select" button underneath that runs a macro opening a form that acts on the selected value. What I can't figure...
2
by: Allan Horwitz | last post by:
When I try to reference the lstproducts.selecteditem.value using autopostback from the lstproducts listbox I get an error? How can I fix my code to get the selected value from the lstproducts...
1
by: Asha | last post by:
greetings, can someone show me how to read a client side value from code behind withouth having to resfresh the page? here is the code i've implemented.... ...
3
by: David | last post by:
Hi If I change the checked value of the checkbox by code, I can not trigger the CheckedChanged event of a checkbox control. Is there any way to implement it? Thank you very much!
1
by: Asha | last post by:
hello, my list box is generated by javascript and in my codebehing if i do a Request.Form i'll get a string to the listbox value e.g. "1,2,3,4," how can i get the text for the listbox as well? any...
3
by: prabu.girirajan | last post by:
Hi, I have a web application which internally calls certain web methods of a web service. This web service has a interop to ATL COM Component and that ATL component calls a .NET assembly. I would...
6
by: George Slamowitz | last post by:
Hello all I have a HTML control generated by the following: INPUT TYPE="hidden" NAME="MyAnswer" VALUE="" Is there a way to reference the Value of this control using VB program code??? ...
2
by: duancg | last post by:
Hi, I wonder if someone could help since I wasn't able to find the answer through search. I have a simple .aspx page that shows data from a database table, as a table in UI. Now the data uses...
6
by: Derek Hart | last post by:
How can I set the listbox value and retrieve a listbox value with just text? I have filled the listbox with items in the items collection property (very simple, just one column of text items). I...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.