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

Depicting Fields from Rows and Updating Others via a Loop

129 100+
I was wondering if you could give me some advice on another issue. I have this code for inserting more details based on the StkID.

Expand|Select|Wrap|Line Numbers
  1. Dim strSQL As String
  2.  
  3.           Dim db As Database
  4.           Dim rst As Recordset
  5. .
  6.           DoCmd.SetWarnings False
  7.  
  8.           DoCmd.GoToRecord , , acFirst
  9.  
  10.           Set db = CurrentDb()
  11.  
  12.           Set rst = db.OpenRecordset("SELECT * FROM preordlin")
  13.         Do
  14.  
  15.               rst.Edit
  16. .
  17.               strSQL = "INSERT INTO preordlin ([OrderNo],[StkID],[StkShortDesc],[Width],[Depth],[Height],[Qty]) SELECT forms!frmCustomerOrderForm!sfrmSOHeader!OrderNo AS OrderNo,[SubStkID],[stkmas.StkShortDesc],preordlin.Width,preordlin.Depth,preordlin.Height,  [Qty] FROM (stkbommas INNER JOIN stkmas ON stkbommas.substkID = stkmas.StkID) WHERE stkbommas.StkID =" & rst!StkID
  18.  
  19.               DoCmd.RunSQL strSQL
  20.  
  21.               rst!SuppNo = DLookup("[SuppNo]", "stkmas", "[StkID] = Forms![frmPreSOLine]![StkID]")
  22.  .
  23.               rst.Update
  24.  .
  25.               rst.MoveNext
  26.  .
  27.           Loop Until rst.EOF
  28.  .
  29.           rst.Close
  30.  .
  31.           Me.Requery
  32.  .
  33.           Set rst = Nothing
  34.  .
  35.            DoCmd.SetWarnings True
  36.  
This code works almost perfectly, however the width, depth and height fields stay fixed to the first record and not change based on the rows. I have just tried changing the code from "preordlin.Width,preordlin.Depth,preordlin.Hei ght" to this "rst!Width,rst!Depth,rst!Height" unfortunately i receive another error asking me to input the fields for rst!Width,rst!Depth,rst!Height. Which works when i input the values in each field for each row. But i want it to establish itself what the values are for each row.

I have changed the code to;

strSQL = "INSERT INTO preordlin ([OrderNo],[StkID],[StkShortDesc],[Width],[Depth],[Height],[Qty]) SELECT forms!frmCustomerOrderForm!sfrmSOHeader!OrderNo AS OrderNo,[SubStkID],[stkmas.StkShortDesc],[preordlin.Width],[preordlin.Depth],[preordlin.Height],[Qty] FROM (stkbommas INNER JOIN stkmas ON stkbommas.substkID = stkmas.StkID) WHERE stkbommas.StkID =" & rst!StkID

This works but only puts values in all the fields based on the first row not changing the fields when the second row has focus within the Loop.

Do you have any advice you could give me please?
Aug 23 '08 #1
1 1182
nico5038
3,080 Expert 2GB
Best to keep your question located in one thread.
It might be confusing for the other experts (and you) when the same problem is posted twice.

I'll close this one for you.

Nic;o)
Aug 24 '08 #2

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

Similar topics

11
by: Jason | last post by:
Let's say I have an html form with 20 or 30 fields in it. The form submits the fields via POST to a php page which updates a table in a database with the $_POST vars. Which makes more sense? ...
3
by: CSDunn | last post by:
Hello, I have a situation with MS Access 2000 in which I need to display report data in spreadsheet orientation (much like a datasheet view for a form). If you think of the report in terms of what...
5
by: bu | last post by:
I have a database field that represents an item description and varying length. I am using the database to import the item description into another program (the other program is ODBC-aware ). The...
5
by: Jeremy | last post by:
This is a variation on the last 2 unresolved questions I've posted. Having removed the "required" attribute from a field that was causing trouble, I'm finding that my dataAdapter update gets...
3
by: Danny Tuppeny | last post by:
Hi all, Something bugs me. It's the whole "not accessing a control from a non-UI thread" thing... In my world, all properties would be safe from all threads (maybe they'd be locked...
24
by: Donald Grove | last post by:
I want to populate an array with values from an ado recordset (multiple rows) I use the absolute position of the cursor in the recordset to define the row of my array to be populated. I have a...
2
by: Alex | last post by:
I am using a web service to update some database fields. I used the dataset designer to define my datatable and tableadapter. I had it automatically create the insert, update, and delete...
2
by: =?Utf-8?B?VmFuZXNzYQ==?= | last post by:
Hi All! I am with a situation where I am not getting the right updating to the form's fields. The situation is the following one: I have one combobox and one textbox. I am using the...
2
by: boss1 | last post by:
hi everyone, i m having a problem with my php update code. i have 7 text fields in a webpage. i have written a code for updating multiple fields in database and it's working properly.but the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
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,...

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.