Hi,
I have a continuous form based on a query.
Lets say the form displays 6 records.
I also have a button against each record which sets a field to Y or N
for each record.
I am trying to copy partial fields only for those records where the
field = Y
My code as follows:
_________________________________
'recordset 1 'rst' is the recordset for the new table
'recordset 2 'rst2' is for the recordset underlying the open form
Dim dbs As Database
Dim rst As DAO.Recordset
Dim rst2 As DAO.Recordset
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("ProductPackREC", dbOpenDynaset)
Set rst2 = Me.RecordsetClone
rst2.MoveFirst
Do While Not rst2.EOF
Me.Text32.SetFocus
If Me.Text32 = "Y" Then
rst.AddNew
rst!packitemNAME = Me!packitemNAME
rst!packitemDESC = Me!packitemDESC
rst!packitemQTY = Me!packitemQTY
rst!packitemCODE = Me!packitemCODE
rst!JobNumber = Me!Text41
rst.Update
Else
End If
rst2.MoveNext
Loop
Set rst = Nothing
Set db = Nothing
______________________________________
What this does is take the first record marked 'Y' and saves the data
correctly, BUT....it records the same record equal to the number of
records on the form !
i.e. if the form displayed
record 1 showed: Blue Y
record 2 showed: Red
record 3 showed: Green Y
record 4 showed: Purple
The new table now shows Blue x 4
If I remove the loop for rst2, then it records the first record marked
with Y only the once, which is correct. What it should do is run
through the forms recordset starting at the first. Check for Y, if
yes, record, if no, movenext.
The new table should now hold :
record 1 : Blue
record 3 : Green
What am I doing wrong, this is driving me crazy. I can only get
multiple copies of the same record recording or 1 copy, but not all
marked Y ?
Appreciate your help.
David 1 1713
"David" <da***@scene-double.co.uk> wrote in message
news:c1**************************@posting.google.c om... Hi,
I have a continuous form based on a query. Lets say the form displays 6 records. I also have a button against each record which sets a field to Y or N for each record.
I am trying to copy partial fields only for those records where the field = Y
My code as follows:
_________________________________
'recordset 1 'rst' is the recordset for the new table 'recordset 2 'rst2' is for the recordset underlying the open form
Dim dbs As Database Dim rst As DAO.Recordset Dim rst2 As DAO.Recordset
Set dbs = CurrentDb Set rst = dbs.OpenRecordset("ProductPackREC", dbOpenDynaset) Set rst2 = Me.RecordsetClone
rst2.MoveFirst
Do While Not rst2.EOF
Me.Text32.SetFocus If Me.Text32 = "Y" Then
rst.AddNew rst!packitemNAME = Me!packitemNAME rst!packitemDESC = Me!packitemDESC rst!packitemQTY = Me!packitemQTY rst!packitemCODE = Me!packitemCODE rst!JobNumber = Me!Text41 rst.Update
Else
End If
rst2.MoveNext
Loop Set rst = Nothing Set db = Nothing
______________________________________
What this does is take the first record marked 'Y' and saves the data correctly, BUT....it records the same record equal to the number of records on the form !
i.e. if the form displayed record 1 showed: Blue Y record 2 showed: Red record 3 showed: Green Y record 4 showed: Purple
The new table now shows Blue x 4 If I remove the loop for rst2, then it records the first record marked with Y only the once, which is correct. What it should do is run through the forms recordset starting at the first. Check for Y, if yes, record, if no, movenext.
The new table should now hold :
record 1 : Blue record 3 : Green What am I doing wrong, this is driving me crazy. I can only get multiple copies of the same record recording or 1 copy, but not all marked Y ?
Appreciate your help.
David
By using "Me" you are referring to the form's current record, when what you
intended to do was to refer to the current record in rst2. So, for example,
instead of Me!packitemNAME, you should use rst2!packitemNAME This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: xool |
last post by:
Hi all, can anyone tell me how to delete just the current record
if tempdate >= todaydate then
Set newMail=Server.CreateObject("CDONTS.newMail")
newMail.to = rs.fields("Email")
newMail.From =...
|
by: Matt |
last post by:
how to get the last record from database without looping?
Whenever the user need to insert a new record to the database, it just
increment the id field by one from the last record.
I tried...
|
by: Chris Thunell |
last post by:
I am looping through a bunch of records in 1 database and putting them into
an ado.net datatable
I get a key violation when i try to add a record... so what i'm trying to do
if that happens, is...
|
by: Mark Vergara |
last post by:
Hi to all,
I want to know if there is a way of getting the position of the
particular record in the dataset aside from CurrencyManger.position
let say for example we have a record..
cntID ...
|
by: Catch_22 |
last post by:
Hi,
I have a stored procedure that has to extract the child records for
particular parent records.
The issue is that in some cases I do not want to extract all the child
records only a...
|
by: Aussie Rules |
last post by:
Hi,
In all my coding to date, i have been dealing with multiple results in my
dataset, looping through them with
SqlDataAdapterContactProfile.Fill(contact, "Profile")
For Each pRow In...
|
by: Richard Hollenbeck |
last post by:
Thanks to everybody who has helped me to get this thing finally working
(somewhat). I got the field names to properly display in the
PageHeaderSection, so I won't post the code from that. Now I'm...
|
by: jags_32 |
last post by:
We have a pretty simple data flow that fetches data from our Source
ERP system and dumps it into a SQL Server table. This functionality
works, what we are trying to do now is to extend this...
|
by: vigneshrao |
last post by:
Hi,
I have been working on a script that loops through multiple records and sends data (one record per call) to a WS.
I am supposed to make a new call for each record before sending the data....
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
|
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,...
|
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...
|
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: 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...
|
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...
| |