for each record action??

piWer

New member
Local time
Today, 15:32
Joined
May 6, 2004
Messages
8
Hi.

I want to asign some actions for each record in query. To be precise it has to write data from query on one Form into FIELDS on another form... otherwords:

CODE on FROM Form

set rst = recordsetclone

For each RECORD(<---do not know what have to be hare) in rst
if field222.text = "some value" then forms!secondform!field1.text = field222
..
..
end if
next

????
How to do this?? i`ve searched for similiar topic on the Web but found nothing :( Help please.
 
couldn't you do a simply update query. This is assuming that the table are linked by an ID number
 
I think not, because i have on one side a form based on a Query with precise Recordset and on another hand a Form based on a Table with 10 fields. and now, if the record from Form 1 contains f.ex word "dog" then code have to put this value into the second Form`s field 1. Sorry but i can`t be more precise. My english is not so fluent ;)

This is easy, but the code have to do this for Every record on form 1. and when i try to do simply if field1.value = "dog" then ....write it to other form`s field ... then the code put`s the last found word on the query.

so i wanted to do For Each ..... in recordsetclone, but do not know how ;/
 
write it to other form`s field
- Forms don't store data, tables store data. Forms are intended to process 1 record at a time. When you reference a form in code, you are referencing the CURRENT record ONLY.

If you want to use one recordset to update another recordset, use an update query or write a sub in a standard module that uses DAO or ADO to read one recordset and update another (the query would be more efficient). Do not use a form for this purpose.

I think not, because i have on one side a form based on a Query with precise Recordset and on another hand a Form based on a Table with 10 fields.
I'm not sure what this has to do with anything. A recordset may be made from a single table or several tables joined together. Queries and tables can be used interchangably so there is nothing to stop you from creating an update query that uses the existing query to update the table.
 
:)
Thx for explanation but now i would be gr8full for an example how to do this.

I think i`ve found a way to describe my situation to You.
I have 2 tables.

One:
id, Field1, Field2, Field3, Field4, Field5, Field6, Field7, Field8, Field9, Field10

Two:
id, Name, Price

Easy. The second table contains Stable names (f.ex. Apple, peach...) and it`s price.

And now i have to put the price.value into one of the Table`s ONE fields, which depends on name.text value.

otherwords (as i wrote before) if name.text = "Apple" then field1.value = price

How to do that??
 
The only way you can do that is with VBA. You'll need to learn to write VBA to do what you want. It might be easier for you to redesign the table since it is not normalized. Your description is criptic but it looks like you took a spreadsheet and called it a table. Do some reading on database design and normalization. Or, if you want to work with a spreadsheet, you will be much happier with Excel.
 
Hmm Pat, thx for explanation but i see that i couldn`t describe it to You well. My english is not very fluent and that`s all. I`ve wrote a Database based on Access which is the only App in my company that the sellers work with, nevermind... Tables are normalized, and forms, etc. I can write everything that uses VBA but when it goes for DAO or ADO or etc. i`m powerless. i`m not writing in VB but in VBA.

Thanks for help guys but i`ll seek elsewhere... maybe in Polish books.
 
I'm sorry but if a VALUE from a column in one table tells you which COLUMN you need in another table, your tables are NOT normalized.
 

Users who are viewing this thread

Back
Top Bottom