473,320 Members | 1,868 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.

Looping within a loop ????

Hi,

I need some help sending records to a variable from a button click on
my form.

I have 3 tables involved.
I need to pull out the first HEADER, then pull out that headers
DETAILS, then move to the next HEADER etc. At the end, a variable named
'specification' should hold all the records.
The HEADERS are related a PRODUCTID, and the DETAILS are related to the
HEADERS.

I keep getting 'Too Few Parameters, expected 1 ?

---------------------------

Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim rst_detail As DAO.Recordset
Dim strSQL As String
Dim strSQL_detail As String
Set dbs = CurrentDb

strSQL = "SELECT specification_ID, specification_header, product_ID
FROM Specifications WHERE product_ID = " & Me.product_ID & ";"

Set rst = dbs.OpenRecordset(strSQL)
If rst.EOF Then
Exit Sub

Else
''''''' get first header ''''''
specification = "<h4>" & rst("specification_header") & "</h4>"

Do While Not rst.EOF

''''''' get first header ID''''''

detailheader = rst("specification_ID")

''''''' find DETAILS for the first HEADER ''''''

strSQL_detail = "SELECT specification_details_text, specification_ID
FROM Specification_detail WHERE specification_ID = " & detailheader &
";"
Set rst_detail = dbs.OpenRecordset(strSQL_detail)
If rst_detail.EOF Then

Else

''''''' Get Details ''''''

specification = specification & "<ul><li>" &
rst_detail("specification_detail_text") & "</li>"
Do While Not rst_detail.EOF
specification = specification & "<li>" &
rst_detail("specification_detail_text") & "</li>"
rst_detail.MoveNext
Loop
specification = specification & "</ul>"
End If

''''''' Mve to next HEADER''''''

rst.MoveNext

specification = specification & "<h4>" & rst("specification_header") &
"</h4>>"
Loop

End If
Me.product_Specs = specification

rst.Close
rst_detail.Close
dbs.Close

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.Close

--------------------------------------

This is quite compliated as there is a loop within a loop ?
Appreciate any help you can give

Thanks

David

Mar 15 '06 #1
2 1827
Which line of code is throwing that error?

Jeremy
--
Jeremy Wallace
Fund for the City of New York
http://metrix.fcny.org

Mar 15 '06 #2
GH
David,

Have you tried adding a break point at the first query call and viewing
strSQL and strSQL_detail in the immediate window? Usually, the error
you are getting indicates that a value is missing in the WHERE clause
of your query string. If you check your two strings in the immediate
window prior to execution, you can see which one is bombing. From
there, you just need to determine why the value of the particular
variable in question is not being set. I did not go over your code
with a fine-toothed comb, but it generally looks fine. I use loops
within loops frequently. Although I would personally would change some
aspects of the code, these changes are irrelevant to your question and
purely my personal coding tastes, which is why I did not specify these
comments. The bottom line is that I recommend debugging the code to
track down which value is not being set, the Me.Product_ID from your
form or the detailheader value from the initial recordset. From there
you should be able to trace why the value is not being set.

- GH

Mar 15 '06 #3

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

Similar topics

5
by: Trevor Perrin | last post by:
After running a simple loop around 100-200 million times, there's a speed drop of about a factor of 7. This happens within several minutes (on a 1.7 Ghz machine), so it's not that hard to see. ...
2
by: Ivo | last post by:
Hi, I have an audio file (.mid or .wav or .mp3) in an object element: <object id="snd" classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95"...
45
by: Trevor Best | last post by:
I did a test once using a looping variable, first dimmed as Integer, then as Long. I found the Integer was quicker at looping. I knew this to be true back in the 16 bit days where the CPU's (80286)...
5
by: masood.iqbal | last post by:
My simplistic mind tells me that having local variables within looping constructs is a bad idea. The reason is that these variables are created during the beginning of an iteration and deleted at...
4
by: Ryan Ternier | last post by:
I'm having an issue with an inner loop. Here's the basic Code: For each......{ //Do code here //start other loop For each....{
2
by: Jim in Arizona | last post by:
Usually, If i need special formatting, I don't use the datagrid control and use a loop that processes a table for each record read from the database (as in classic asp) like so: ...
5
by: Jeff | last post by:
Hey gang. I have a script that gets stats from a mssql db, and then inserts those stats into a temp table. where i can work with them as i wish. the problem is it isn't looping through all the...
6
by: Luke - eat.lemons | last post by:
Hi, Im pretty new to asp so all light on this question would be great. Basically i need to test to see what value is set (where to retrieve the data from) so ive done it like this: If...
10
by: Charlie Brown | last post by:
I am using something like the following function to loop through a recipe program I am working on. As I was writing it, I starting thinking this isn't going to work at all... but not I'm not so...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
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...
0
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)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.