472,958 Members | 1,948 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,958 software developers and data experts.

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_AfterUpdate()

Me.Subfrm_ProductionData!txtMarks.DefaultValue = Me.txtMarks

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

Me.Subfrm_ProductionData.Requery

End Sub
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #1
3 13740
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******@pcdatasheet.com
www.pcdatasheet.com
"Anthony Kroes" <tk****@baytowel.com> wrote in message
news:40*********************@news.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_AfterUpdate()

Me.Subfrm_ProductionData!txtMarks.DefaultValue = Me.txtMarks

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

Me.Subfrm_ProductionData.Requery

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.RecordsetClone is for the main form's recordset, not the subform's...

Try it like this:

Private Sub txtMarks_AfterUpdate()

' Me.Subfrm_ProductionData!txtMarks.DefaultValue = 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_ProductionData].Form.RecordsetClone

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_ProductionData.Requery
Set rst = Nothing
End Sub
--
HTH,
Don
=============================
Use My*****@Telus.Net 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****@baytowel.com> wrote in message
news:40*********************@news.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_AfterUpdate()

Me.Subfrm_ProductionData!txtMarks.DefaultValue = Me.txtMarks

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

Me.Subfrm_ProductionData.Requery

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
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...
7
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...
4
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. ...
5
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...
9
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...
10
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...
2
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...
3
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: ...
2
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...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.