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.OpenRecords et("ProductPack REC", dbOpenDynaset)
Set rst2 = Me.RecordsetClo ne
rst2.MoveFirst
Do While Not rst2.EOF
Me.Text32.SetFo cus
If Me.Text32 = "Y" Then
rst.AddNew
rst!packitemNAM E = Me!packitemNAME
rst!packitemDES C = Me!packitemDESC
rst!packitemQTY = Me!packitemQTY
rst!packitemCOD E = 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 1730
"David" <da***@scene-double.co.uk> wrote in message
news:c1******** *************** ***@posting.goo gle.com... 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.OpenRecords et("ProductPack REC", dbOpenDynaset) Set rst2 = Me.RecordsetClo ne
rst2.MoveFirst
Do While Not rst2.EOF
Me.Text32.SetFo cus If Me.Text32 = "Y" Then
rst.AddNew rst!packitemNAM E = Me!packitemNAME rst!packitemDES C = Me!packitemDESC rst!packitemQTY = Me!packitemQTY rst!packitemCOD E = 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!packitemNA ME 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 = "info@someone.biz"
newMail.Subject = "Wavestation Present Planner"
newMail.Body = "Dear " & rs.fields("qName") & vbcrlf & vbcrlf & "This is
your present planner reminder." & vbcrlf & vbcrlf & "It's " &
rs.fields("Period") & " before " &...
|
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 objRS.MoveLast, but it wont work.
|
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 skip that record and move on to the next record... I
haven't quite figured out the Try / Catch scenario. Here is my code:
Try
Me.DataSet11.tblContact.Rows.Add(myNewRow)
|
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 Name
1 Richard
2 Lucas
3 Jesus
|
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 certain number of them.
Firstly I identify all the parent records that have the requird number
of child records and insert them into the result table.
| |
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 contact.Tables("Profile").Rows
|
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 trying to
populate the records (this is based on a cross-tab query "qryTableOfGrades"
in the Detail section but it only displays the data from the last record in
every record. Here's the code. I wonder what I'm doing wrong:
Private Sub...
|
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 functionality by
looping through a table in SQL Server which has a list of all ODBC
connections, changing the source connection dynamically. How do I do
this? For some reason, the SQL Server online tutorial is useless since
it just deals with file...
|
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.
The problem I have is the first record gets processed fine where as the second record always; reason being the EAI expects it to be a seperate call
Though I am creating/reseting a new service everytime within the foreach loop the data seems to be...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
| |
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |