473,408 Members | 1,734 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,408 software developers and data experts.

displaying search result in an excel format or else

I have created a table in access (copied from excel). Then I created a form which contains a text field and a list box. The text field is actually a look-up field, where a user can enter a searchable text and the results are displayed in the list box(the search is done on the table which I copied from excel). Everything works fine as I want.
The problem: I cannot copy the results from that list box to the excel sheet. It just copies the first column of the displayed rows in the list box. I had tried using a command button to display the result in the tabular-excel form, but it only takes a pre-defined saved query. I can't save the query as it is generated based on the search key word a user enters in the text box.
How can I display the results in some kind of format that can be copied/ exported to the excel sheet? Can anyone suggest something ?.
My code is :
Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2.  
  3. Private Sub List3_BeforeUpdate(Cancel As Integer)
  4.  
  5.  
  6. End Sub
  7.  
  8. Private Sub Text0_BeforeUpdate(Cancel As Integer)
  9.     Dim holdVal As String
  10.     holdVal = Me.Text0.Value
  11.     Me.List3.RowSourceType = "Table/Query"
  12.     Me.List3.RowSource = "SELECT * FROM Contents" & _
  13.                             " WHERE PART_NUM LIKE '" & holdVal & "*'"
  14.     Me.List3.Requery
  15.  
  16. End Sub
  17.  
and when I try to insert the code for command button, replacing the stored query with mine, I get the error that it cannot find the object and then list my generated query. Code for that part is:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Get_Fields_Click()
  2. On Error GoTo Err_Get_Fields_Click
  3.  
  4.     Dim storeVal As String
  5.     storeVal = Me.Text0.Value
  6.     Dim qrRetrieve As String
  7.     qrRetrieve = "SELECT * FROM Contents" & _
  8.                             " WHERE PART_NUM LIKE '" & storeVal & "*'"
  9.     DoCmd.OpenQuery qrRetrieve, acNormal, acEdit
  10.  
  11.  
  12. Exit_Get_Fields_Click:
  13.     Exit Sub
  14.  
  15. Err_Get_Fields_Click:
  16.     MsgBox Err.Description
  17.     Resume Exit_Get_Fields_Click
  18.  
  19. End Sub
  20.  
Thanks !
Jul 19 '07 #1
2 2176
I have created a table in access (copied from excel). Then I created a form which contains a text field and a list box. The text field is actually a look-up field, where a user can enter a searchable text and the results are displayed in the list box(the search is done on the table which I copied from excel). Everything works fine as I want.
The problem: I cannot copy the results from that list box to the excel sheet. It just copies the first column of the displayed rows in the list box. I had tried using a command button to display the result in the tabular-excel form, but it only takes a pre-defined saved query. I can't save the query as it is generated based on the search key word a user enters in the text box.
How can I display the results in some kind of format that can be copied/ exported to the excel sheet? Can anyone suggest something ?.
My code is :
Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2.  
  3. Private Sub List3_BeforeUpdate(Cancel As Integer)
  4.  
  5.  
  6. End Sub
  7.  
  8. Private Sub Text0_BeforeUpdate(Cancel As Integer)
  9.     Dim holdVal As String
  10.     holdVal = Me.Text0.Value
  11.     Me.List3.RowSourceType = "Table/Query"
  12.     Me.List3.RowSource = "SELECT * FROM Contents" & _
  13.                             " WHERE PART_NUM LIKE '" & holdVal & "*'"
  14.     Me.List3.Requery
  15.  
  16. End Sub
  17.  
and when I try to insert the code for command button, replacing the stored query with mine, I get the error that it cannot find the object and then list my generated query. Code for that part is:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Get_Fields_Click()
  2. On Error GoTo Err_Get_Fields_Click
  3.  
  4.     Dim storeVal As String
  5.     storeVal = Me.Text0.Value
  6.     Dim qrRetrieve As String
  7.     qrRetrieve = "SELECT * FROM Contents" & _
  8.                             " WHERE PART_NUM LIKE '" & storeVal & "*'"
  9.     DoCmd.OpenQuery qrRetrieve, acNormal, acEdit
  10.  
  11.  
  12. Exit_Get_Fields_Click:
  13.     Exit Sub
  14.  
  15. Err_Get_Fields_Click:
  16.     MsgBox Err.Description
  17.     Resume Exit_Get_Fields_Click
  18.  
  19. End Sub
  20.  
Thanks !
Hi

Have to make this quick as I have a train to catch!

Use the Column function

Expand|Select|Wrap|Line Numbers
  1. public vValArray ()
  2.  
  3. Redim vValArray(me.ListBox.ListCount)
  4.  
  5. For vloop 0 to ListBox.Listcount
  6. vValArray(vloop) = ListBox.Column(Column,vloop) ' (vloop is each row in the 
  7. listbox)
  8. Netx vloop
  9.  
  10.  
vValArray(n) now contains each value, if you want this to only to apply to the values selected then use

Expand|Select|Wrap|Line Numbers
  1.  If me.Listbox.Selected(vloop) = True then 
and don't forget to change the properties of the listbox to Multiselect = Simple.

Daz
Jul 19 '07 #2
didn't work, can you explain a bit more ?
thanks
Jul 20 '07 #3

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

Similar topics

2
by: jaysonsch | last post by:
Hello! I am having some problems with a database query that I am trying to do. I am trying to develop a way to search a database for an entry and then edit the existing values. Upon submit, the...
13
by: Allison Bailey | last post by:
Hi Folks, I'm a brand new Python programmer, so please point me in the right direction if this is not the best forum for this question.... I would like to open an existing MS Excel spreadsheet...
6
by: Alec | last post by:
Newbie question. I have a database for displaying the names of bed and breakfasts searched for by the town they are in as below. <?php $result = @mysql_query ("SELECT name FROM...
9
by: jillandgordon | last post by:
I am trying to import an excel file into Access 97. It looks perfectly all right but, every time I try to import it, I get to the lst step and am told that it was not imported due to an error. ...
3
by: Russell | last post by:
Hey, ok i have numerous tables to search through for a 'site search'. some of the searchble fields have html embeded within so after some quick referencing, saw I can use the regExp function...
4
by: BenCoo | last post by:
Hello, In a Binary Search Tree I get the error : Object must be of type String if I run the form only with the "Dim bstLidnummer As New BinarySearchTree" it works fine. Thanks for any...
13
by: David W. Fenton | last post by:
I've been struggling the last two days with something I thought was very easy, which is to open a web page with a form on it and populate the form with data passed in a query string (either POST or...
7
by: TG | last post by:
hi! I am trying to create a sql server table from an excel sheet. Here is the code I have: 'This procedure the xlsx file and dumps it to a table in SQL Server
7
by: RichB | last post by:
I am trying to get to grips with the asp.net ajaxcontrol toolkit, and am trying to add a tabbed control to the page. I have no problems within the aspx file, and can dynamically manipulate a...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.