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

run sql query for each record in a contious form

Greetings,

I'm trying to run a sql query on a continous form. I have the
query working correctly the way I want it. I want this query to be
displayed on the form in the text box on the load event of the form.
Each record in the continous form should have different results for the
same query. My query bases the results on a Where condition of the
primary key of the table. So when the form loads, it displays only the
results for the first item in the query. The first record will have
the correct query result. Each succeeding record will show the results
for the first record. How can I correct this in vba? Here is my code
snippet:

Private Sub Form_Load()

Dim SQLString As String
Dim db As dao.Database
Dim rs As dao.Recordset
Dim tests As String

'me.testnumber is the primary key
Set db = CurrentDb
SQLString = "SELECT DISTINCT Test, TestNumber FROM DATA WHERE
TestNumber = " &
Me.TestNumber.Value

Set rs = db.OpenRecordset(SQLString)

tests = "Tests:" & Chr(13) & Chr(9)
Do While rs.EOF = False
tests = tests & rs.Fields("Test").Value & Chr(13) & Chr(9)
rs.MoveNext
Loop

rs.Close
Set rs = Nothing

'display result
Me.txtResult.Value = tests

End

Regards,
Kevin

Dec 9 '05 #1
1 4639
why not just pass in the primary key of the parent record? Then you'd
get a recordset of the child records and could manipulate that way?

Dec 9 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: John Baker | last post by:
HI: I have a situation where I wish to enter a value in an unbound field on a form and then change the same field in each record on the form so that it reflects the value entered. THe form is...
3
by: JC Mugs | last post by:
Help needed for project-Access 2002(office xp) PROBLEM: Figuring out how to lookup a record and DDate field in Table1 - Take that DDate-field data from record looked up and assign it to Date...
1
by: Robert Neville | last post by:
The solution to my dilemma seems straight-forward, yet my mind has not been forthcoming with a direct route. My Project form has a tab control with multiple sub-forms; these distinct sub-forms...
5
by: Lyn | last post by:
This one is difficult to explain, so I will cut it down to the basics. I have a major table 'tblA' which has an autonum field 'ID-A' as primary key (of no significance to users). 'tblA' contains...
1
by: Thelma Lubkin | last post by:
I have a form that displays and allows user to edit colorsets, each colorset containing between 3and 11 colors. Each individual color is a combination of numerical values of Red,Blue, and Green. ...
6
by: kenshiro | last post by:
Hi All, I'm having a problem with some VBA code in one of my Access 2003 databases. I'm getting the following error when running code behind a command button on a form: "Item not found in this...
8
by: chrisdavis | last post by:
I'm trying to filter by query or put those values in a distinct query in a where clause in some sort of list that it goes through but NOT at the same time. Example: ROW1 ROW2 ROW3 ROW4 ,...
6
by: Phil Stanton | last post by:
I am running a query that calls a function used to format addresses depending on the width of a control on a report that shows that address. The same query is used as the RecordSource of lots of...
8
by: olivero | last post by:
Hi group, Is there an easy way to make a form create the same set of fields dynamically, once for each record returned by a query? I have a query that's being called from a form and the results...
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...
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:
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
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...

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.