473,503 Members | 1,834 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Display query resultS in text box

74 New Member
(Yes... i capitalized the S on purpose)
I didnt know before today that dlookup only found the first result. I am actually trying to display the results of a query in a report, but there are multiple records being returned... (sometimes as many as 500). I know there is probably another way of acheiving this, but i was hoping to be able to use something like dlookup, with a text box with "can grow: yes" , so that it would only be as big as it needed to be, i tried using a listbox, but they cant grow :(

If anybody knows how to complete this, please let me know.
May 13 '09 #1
4 10510
ChipR
1,287 Recognized Expert Top Contributor
List boxes can't grow, but they can scroll. I'm not sure that using a text box for this is the best solution, but it's certainly possible. If you want to get data from a bunch of results, you can put them in a recordset and step through it. Here's an example.

Expand|Select|Wrap|Line Numbers
  1.     Dim records As Object 
  2.     Dim db As Object 
  3.     Dim strText as String
  4.  
  5.     Set db = CurrentDb() 
  6.     Set records = db.openrecordset("query1") 
  7.  
  8.     strText = ""
  9.     While Not records.EOF
  10.         strText = strText & records!fieldName & vbCrLf
  11. 'vbCrLf is an endline, " " for a space
  12.         records.movenext 
  13.     Wend 
  14.  
  15.     txtBox1 = strText
  16.  
  17.     records.Close 
  18.     Set records = Nothing 
  19.     Set db = Nothing 
  20. Exit Sub
Just don't forget the records.MoveNext!
May 13 '09 #2
NeoPa
32,557 Recognized Expert Moderator MVP
May I suggest that, unless you have compelling reasons to do it this way, you take a more standard and manageable approach and design the report (or even a subreport if the main report is already bound) to use that particular data source.
May 13 '09 #3
kstevens
74 New Member
Thanks for the advice. I ended up putting a subreport.... much easier, and looks great. Dont know why i didnt do it in the first place.
May 15 '09 #4
NeoPa
32,557 Recognized Expert Moderator MVP
I expect that's simply about experience.

I still struggle to think of the best way to do things in new areas that I've not had much previous experience in.
May 15 '09 #5

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

Similar topics

2
1953
by: erica | last post by:
Hi, I am currently writing PHP code for some polling software. When someone votes, it stores their IP address in the database. From then on, they cannot vote in that particular poll, they only...
3
9468
by: deko | last post by:
I store hyperlinks as text in a table like this: Invoice11-21-2003.pdf#file://P:\Finance\PrefVendors\Receipts\Invoice11-21-20 03.pdf I need to run a report that lists the documents - or...
3
12691
by: matthewemiclea | last post by:
I am trying to display information in Access on a form that takes information from many different queries and puts them together on a spreadsheet or chart. Some specific info: The information I...
3
4014
by: google | last post by:
This is something I've done plenty of times in '97, but I can't seem to get it to work correctly in Access 2003. Say, for example, I have a form with an unbound combobox, the data source is a...
2
2322
by: Steven Smith | last post by:
Hi guys What I'm trying to do today is display the results from an SQL query on one table in a Datagrid I'm using the following code to query the table. \\\ Try If...
5
2744
by: PHPBABY3 | last post by:
Hi, 1. I have two SQL tables. I will call them employees and departments: EMP: LAST_NAME, FIRST_NAME, DEPTNM DEPT: NUM, NAME Input: text string FIND Output: the LAST_NAME, FIRST_NAME...
4
2407
by: rn5a | last post by:
A MS-Access DB has 3 tables - Teacher, Class & TeacherClass. The Teacher table has 2 columns - TeacherID & TeacherName (TeacherID being the primary key). The Class table too has 2 columns - ClassID...
16
7939
by: dougmeece | last post by:
Good day everyone, I have a database with 2 main forms. The first form is used to add records to the database and contains a command button that opens the 2nd form for records searching. On...
4
13677
by: Yitzak | last post by:
Have a query that is arregated into crosstab query, it is working correctly. select Yes as selected from tblname or select true as selected from tblname Produces -1 ( vba value of True) in...
3
4824
WyvsEyeView
by: WyvsEyeView | last post by:
This seems like it should be so easy to do. I have a table, called tblTopics. Each topic can have one or more instances, contained in a table called tblTopicInst. tblTopics is bound to a form called...
0
7199
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
7076
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7323
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...
1
6984
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
7453
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
5576
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,...
1
5005
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
4670
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...
0
1507
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.