473,407 Members | 2,598 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,407 software developers and data experts.

Query problems

I have a query which works perfectly but I wish to iterate through the query and select specific portions from the query such as ID, address which can then be sent to perform another function.

My current solution is to fill a listbox with the required information however I have no idea how to extract the values, I have tried a solution with combobox however, upon iterating through all the items to select them the items remain unselected and thus Comobox.text has a null value.

Any help would be appreciated.
Aug 13 '08 #1
10 1538
ADezii
8,834 Expert 8TB
We will need much more detail that that which you have provided, such as:
  1. Table the Query is based on.
  2. Field Names and their Data Types that comprise the Query.
  3. Specific Fields you wish to extract.
  4. Where do you wish to extract these Field values to? List Box, Combo Box, etc.
  5. What is the Name of the Object that will accept these values?
  6. etc...
Aug 13 '08 #2
1. Table the Query is based on.
2. Field Names and their Data Types that comprise the Query.
3. Specific Fields you wish to extract.
4. Where do you wish to extract these Field values to? List Box, Combo Box, etc.
5. What is the Name of the Object that will accept these values?
6. etc...


The table the query is based on is a generic table (tbl1) all field names are based on client listing, the ones that the comprise the query are CandidateName, phone, email. all of which are text data type.
I wish to extract the phone data from the query into a listbox/combobox then into a memo box

Since the listbox/combobox already contains the data items i wish to extract I would like to know how to extract the information from the listbox and put into the memo box, or would it be simpler to use a recordset and iterate through the set returned by the query?
Aug 13 '08 #3
ADezii
8,834 Expert 8TB
1. Table the Query is based on.
2. Field Names and their Data Types that comprise the Query.
3. Specific Fields you wish to extract.
4. Where do you wish to extract these Field values to? List Box, Combo Box, etc.
5. What is the Name of the Object that will accept these values?
6. etc...


The table the query is based on is a generic table (tbl1) all field names are based on client listing, the ones that the comprise the query are CandidateName, phone, email. all of which are text data type.
I wish to extract the phone data from the query into a listbox/combobox then into a memo box

Since the listbox/combobox already contains the data items i wish to extract I would like to know how to extract the information from the listbox and put into the memo box, or would it be simpler to use a recordset and iterate through the set returned by the query?
Since the listbox already contains the data items i wish to extract I would like to know how to extract the information from the listbox and put into the memo box
  1. What exactly do you mean by Memo Box?
  2. In what format do the wish the Phone Numbers in the List/Combo Box extracted? e.g.
    Expand|Select|Wrap|Line Numbers
    1. (215) 888-1234;(234) 876-8936;(679)-0018
    Expand|Select|Wrap|Line Numbers
    1. (215) 888-1234
    2. (234) 876-8936
    3. (679)-0018
    Expand|Select|Wrap|Line Numbers
    1. (215) 888-1234, (234) 876-8936, (679)-0018
Aug 13 '08 #4
1. What exactly do you mean by Memo Box?
2. In what format do the wish the Phone Numbers in the List/Combo Box extracted? e.g.
Code: ( text )
1.
(215) 888-1234;(234) 876-8936;(679)-0018

Code: ( text )
1.
(215) 888-1234
2.
(234) 876-8936
3.
(679)-0018

Code: ( text )
1.
(215) 888-1234, (234) 876-8936, (679)-0018

I would prefer the phone numbers to be extracted as your third example shows,
by memo box i mean a textual area sorry for confusion
Aug 13 '08 #5
ADezii
8,834 Expert 8TB
I would prefer the phone numbers to be extracted as your third example shows,
by memo box i mean a textual area sorry for confusion
Stand by, I should have an answer for you within a couple of hours. Oops, here comes the boss, gotta go! (LOL).
Aug 13 '08 #6
ADezii
8,834 Expert 8TB
Stand by, I should have an answer for you within a couple of hours. Oops, here comes the boss, gotta go! (LOL).
OK, boss has gone. Assuming your List Box is named lstPhone and your Text Box is named txtPhoneNos, the following code will do the trick:
Expand|Select|Wrap|Line Numbers
  1. Dim strBuild As String
  2. Dim intCounter As Integer
  3. Dim intNumOfEntries As Integer
  4.  
  5. intNumOfEntries = Me![lstPhone].ListCount
  6.  
  7. If intNumOfEntries > 0 Then
  8.   For intCounter = 0 To intNumOfEntries - 1
  9.     strBuild = strBuild & Me![lstPhone].ItemData(intCounter) & ", "
  10.   Next
  11.   Me![txtPhoneNos] = Left$(strBuild, Len(strBuild) - 2) 'remove trailing ", "
  12. Else
  13.   Me![txtPhoneNos] = vbNullString
  14. End If
Aug 13 '08 #7
thanks the help is appreciated
Aug 13 '08 #8
ADezii
8,834 Expert 8TB
thanks the help is appreciated
You are quite welcome.
Aug 13 '08 #9
OK, boss has gone. Assuming your List Box is named lstPhone and your Text Box is named txtPhoneNos, the following code will do the trick:
Expand|Select|Wrap|Line Numbers
  1. Dim strBuild As String
  2. Dim intCounter As Integer
  3. Dim intNumOfEntries As Integer
  4.  
  5. intNumOfEntries = Me![lstPhone].ListCount
  6.  
  7. If intNumOfEntries > 0 Then
  8.   For intCounter = 0 To intNumOfEntries - 1
  9.     strBuild = strBuild & Me![lstPhone].ItemData(intCounter) & ", "
  10.   Next
  11.   Me![txtPhoneNos] = Left$(strBuild, Len(strBuild) - 2) 'remove trailing ", "
  12. Else
  13.   Me![txtPhoneNos] = vbNullString
  14. End If
Hi, this code is cool. Now, what I'm tryin is to iterate thru the second column of the combo box as my combo box has two columns. What it will do is iterate through the second column and compare values in those columns with the one passed and if matched it will return the value in the same row but from the first column. Can you please help me how I can achieve this. Thank you.
Sep 5 '08 #10
ADezii
8,834 Expert 8TB
Hi, this code is cool. Now, what I'm tryin is to iterate thru the second column of the combo box as my combo box has two columns. What it will do is iterate through the second column and compare values in those columns with the one passed and if matched it will return the value in the same row but from the first column. Can you please help me how I can achieve this. Thank you.
I'm a little fuzzy on your request, but here is generic code that will iterate through all Values in the 2nd Column of a Combo Box named cboNames, and compare them to an Unknown Value:
Expand|Select|Wrap|Line Numbers
  1. Dim intCounter As Integer
  2. Dim intNumOfEntries As Integer
  3.  
  4. intNumOfEntries = Me![cboNames].ListCount
  5.  
  6. If intNumOfEntries > 0 Then
  7.   For intCounter = 0 To intNumOfEntries - 1
  8.     If Me![cboNames].Column(1, intCounter) = "<some value>" Then
  9.        'take some action here
  10.     End If
  11.   Next
  12. End If
Sep 5 '08 #11

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

Similar topics

6
by: carverk | last post by:
Hello All I'm in the middle of moving a MS Access DB to a MySql backend. I have figured out about 90% of the problems I have faced, execpt for this one. I have 3 Queries, which pull records...
0
by: Mike N. | last post by:
Hello to all: First let me apologize for the length of this question, I've made an attempt to include as much information as is needed to help with the question. I am having problems putting...
1
by: Jeff Blee | last post by:
I hope someone can help me get this graph outputing in proper order. After help from Tom, I got a graph to display output from the previous 12 months and include the average of that output all in...
5
by: sulemanzia | last post by:
hi. i am working first time with query and reports. i have created a database. i have reports and query. i have a button in my form by the name of (View reports) if a user clicks on that button it...
3
by: faceman28208 | last post by:
Over the past few years I have consulted on six large projects that all independently arrived at the same moronic design desision: The use of SQL query classes. No, I don't mean a class...
22
by: Stan | last post by:
I am working with Access 2003 on a computer running XP. I am new at using Access. I have a Db with a date field stored as mm/dd/yyyy. I need a Query that will prompt for the month, ie. 6 for...
6
by: gerbski | last post by:
Hi all, I am relatively new to ADO, but up to now I got things working the way I wanted. But now I've run into somethng really annoying. I am working in MS Access. I am using an Access...
2
by: webhead74 | last post by:
Hi, I'm having intermittent problems with queries from my php script to a postgresql database. I have a form where I can enter a search query - for instance a last name. This leads to a...
16
by: ARC | last post by:
Hello all, So I'm knee deep in this import utility program, and am coming up with all sorts of "gotcha's!". 1st off. On a "Find Duplicates Query", does anyone have a good solution for...
9
by: Bob Darlington | last post by:
The following query opens slowly the first time it is opened (6-7 seconds), but then is less than one second for the next random number of openings before slowing (6-7 seconds) again. SELECT...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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,...

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.