473,545 Members | 2,042 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Editing records from recordsetclone


I have a subform on a form and they are not linked. On the main form is
a text box where the user types in a number. When that number changes,
I have some code to make the corresponding text field in the subform
default its value so that the next record created uses the value from
the box on the main form. So far so good - works fine.

What I also need to do at the same time is change all *existing* records
on the subform to that same value. I am trying to do this via editing
the recordsetclone, but nothing seems to change - how do I write changes
made to that to the real recordset? Existing code listed below.

Thanks,

Private Sub txtMarks_AfterU pdate()

Me.Subfrm_Produ ctionData!txtMa rks.DefaultValu e = Me.txtMarks

Dim db As Database
Dim rst As Recordset
Set rst = Me.RecordsetClo ne
With rst
.MoveFirst
Do While Not .EOF
.Edit
!Marks = Me.txtMarks
.Update
.MoveNext
Loop
End With

Me.Subfrm_Produ ctionData.Reque ry

End Sub
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #1
3 13936
Anthony,

The key is to have a way to determine which records are "Existing" records on
the subform. Once you are able to do that, then you can use an Update query to
change the "existing" records to the same value.

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdata sheet.com
www.pcdatasheet.com
"Anthony Kroes" <tk****@baytowe l.com> wrote in message
news:40******** *************@n ews.frii.net...

I have a subform on a form and they are not linked. On the main form is
a text box where the user types in a number. When that number changes,
I have some code to make the corresponding text field in the subform
default its value so that the next record created uses the value from
the box on the main form. So far so good - works fine.

What I also need to do at the same time is change all *existing* records
on the subform to that same value. I am trying to do this via editing
the recordsetclone, but nothing seems to change - how do I write changes
made to that to the real recordset? Existing code listed below.

Thanks,

Private Sub txtMarks_AfterU pdate()

Me.Subfrm_Produ ctionData!txtMa rks.DefaultValu e = Me.txtMarks

Dim db As Database
Dim rst As Recordset
Set rst = Me.RecordsetClo ne
With rst
.MoveFirst
Do While Not .EOF
.Edit
!Marks = Me.txtMarks
.Update
.MoveNext
Loop
End With

Me.Subfrm_Produ ctionData.Reque ry

End Sub
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 12 '05 #2
Hi Anthony,

I think your problem is that you are attempting to edit the wrong
recordset...
Me.RecordsetClo ne is for the main form's recordset, not the subform's...

Try it like this:

Private Sub txtMarks_AfterU pdate()

' Me.Subfrm_Produ ctionData!txtMa rks.DefaultValu e = Me.txtMarks ' You don't
need this

' Dim db As Database ' You don't need this either

Dim rst As DAO.Recordset
Set rst = Me![Subfrm_Producti onData].Form.Recordset Clone

With rst
.MoveLast
.MoveFirst

Do While Not .EOF ' Hmmm.... This code will run until it hits the last
record...
.Edit
!Marks = Me.txtMarks
.Update

If Not .EOF Then 'Without this, won't it respond with a "No
Current Record" error?
.MoveNext
End If
Loop

..Close
End With

Me.Subfrm_Produ ctionData.Reque ry
Set rst = Nothing
End Sub
--
HTH,
Don
=============== ==============
Use My*****@Telus.N et for e-mail
Disclaimer:
Professional PartsPerson
Amateur Database Programmer {:o)

I'm an Access97 user, so all posted code
samples are also Access97- based
unless otherwise noted.

Do Until SinksIn = True
File/Save, <slam fingers in desk drawer>
Loop

=============== =============== ==


"Anthony Kroes" <tk****@baytowe l.com> wrote in message
news:40******** *************@n ews.frii.net...

I have a subform on a form and they are not linked. On the main form is
a text box where the user types in a number. When that number changes,
I have some code to make the corresponding text field in the subform
default its value so that the next record created uses the value from
the box on the main form. So far so good - works fine.

What I also need to do at the same time is change all *existing* records
on the subform to that same value. I am trying to do this via editing
the recordsetclone, but nothing seems to change - how do I write changes
made to that to the real recordset? Existing code listed below.

Thanks,

Private Sub txtMarks_AfterU pdate()

Me.Subfrm_Produ ctionData!txtMa rks.DefaultValu e = Me.txtMarks

Dim db As Database
Dim rst As Recordset
Set rst = Me.RecordsetClo ne
With rst
.MoveFirst
Do While Not .EOF
.Edit
!Marks = Me.txtMarks
.Update
.MoveNext
Loop
End With

Me.Subfrm_Produ ctionData.Reque ry

End Sub
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 12 '05 #3

Thanks for the replies - as Don pointed out, the problem is (was!) that
I was using the recordsetclone of the main form when I should have been
using the one from the subform. Stupid oversight, but I was focused on
the code, not the bigger picture.

Thanks for the help and all the suggestions. You have a great forum
here!
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #4

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

Similar topics

3
680
by: Anthony Kroes | last post by:
I have a subform on a form and they are not linked. On the main form is a text box where the user types in a number. When that number changes, I have some code to make the corresponding text field in the subform default its value so that the next record created uses the value from the box on the main form. So far so good - works fine. ...
7
1703
by: amywolfie | last post by:
Is there a simple way to code: If (no related records) in VBA? I would be going from frmMain to frm2, where frm2 may or may not have a related record. I do have a PK_ID in frmMain and a FK_ID in frm2.
4
9524
by: amywolfie | last post by:
I would like to put code behind a Find button on a form which: 1) Performs a find based on a field on the form 2) If NO RECORDS ARE FOUND, then displays a custom "No Records Found" message box. Thanks!! amy ===
5
3080
by: highway of diamonds | last post by:
I have a form based on a query. I would like to generate a msgbox and close the form should the query return no records. TIA R. PS I would even be happy to lose the form and just do the same with the query in datasheet view.
9
4791
by: Sandy | last post by:
Hi all, I have a form to list records (frmListIssue) which I call from different other forms. My wish is to display a message when the form is called and empty; no records to display. I want to use OpenArgs because sometimes I don't want an empty form and sometime I don't. I tried everything, but until now without success. I hope that...
10
3599
by: Thelma Lubkin | last post by:
My form/subform combination that allows user to display 'ColorSet' records, move to other records via a selector, to add,delete, and edit them, and to manage the related 'Color' records from the subform is close to completion, but I still need help... The parent form's recordset has fields string integer COLORNAME CLASSSIZE and a few...
2
6322
by: allyn44 | last post by:
Hello, I have built a serch form for users to edit records. I only want them to pull up the record they need, and I want to check for nulls. There should not be dupes becasue the underlying tables are indexed. So the user will pull up either one record or none. Here is my problem: I pass the form name through a tmpvariable and ther other...
3
3439
by: melnhed | last post by:
---Report the current filtered records from a Form--- Hello All, I've seen this topic discussed before, but the solution described then doesn't work in my particular case. My Config: Access 2002 front-end using SQL Server 2000 (MSDE actually) via ADP/ADE Access Data Project.
2
2865
by: Certys | last post by:
Hello, I have a form where I only allow new records to be added. I enable this by setting the form property "Data Entry" to Yes. I want to access other records in the same table- to autofill the new record with a user select previous record. Dim rs As Recordset Set rs = Me.RecordsetClone
0
7410
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7437
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...
0
7773
tracyyun
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...
0
5984
agi2029
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...
1
5343
isladogs
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...
0
3466
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...
0
3448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1901
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
1
1025
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.