473,394 Members | 1,773 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Looping in a Subform

The following code is part of a button (on click) that places a check (true) in a filtered subform. The subform is a set of continuous forms. The checks are placed but it gives an error message that it can’t go to the next record. When I try to step through it, a check is placed in the first record but errors out before it starts to loop?
Expand|Select|Wrap|Line Numbers
  1. x = Me.Text6
  2. Screen.PreviousControl.SetFocus
  3. DoCmd.GoToRecord , , acFirst
  4.  
  5.     Do While x > 1
  6.     Me.Check48 = True
  7.     DoCmd.GoToRecord , , acNext
  8.     x = x - 1
  9.     Loop
Feb 27 '08 #1
6 2137
Stewart Ross
2,545 Expert Mod 2GB
...The checks are placed but it gives an error message that it can’t go to the next record. When I try to step through it, a check is placed in the first record but errors out before it starts to loop?

x = Me.Text6
Screen.PreviousControl.SetFocus
DoCmd.GoToRecord , , acFirst

Do While x > 1
Me.Check48 = True
DoCmd.GoToRecord , , acNext
x = x - 1
Loop
When you say it errors before it starts to loop, is it when you execute the Docmd.GotoRecord statement? If so, it is likely to be because you have not stored the current record which has been updated. If the error is at the GotoRecord, add a save statement just before it:
Expand|Select|Wrap|Line Numbers
  1. DoCmd.Save ,,
-Stewart
Feb 27 '08 #2
NeoPa
32,556 Expert Mod 16PB
Can you tell us which line the error occurs on and what the error message is?
Feb 28 '08 #3
the error occurs at the "DoCmd.GoToRecord , , acNext"

I have added a save just before the DoCmd.GoToRecord , , acNext:
Expand|Select|Wrap|Line Numbers
  1.     Do While x > 0
  2.     Me.Check48 = True
  3.     DoCmd.Save
  4.     DoCmd.GoToRecord , , acNext
  5.     x = x - 1
  6.     Loop
However, this still results in the same error
Feb 28 '08 #4
NeoPa
32,556 Expert Mod 16PB
... and what the error message is?
Feb 28 '08 #5
Sorry...

Run-time error '2105':

You cant go to the specified record
Feb 28 '08 #6
NeoPa
32,556 Expert Mod 16PB
I would have expected that Scott was right about the save. I can see no other reason why going to the next record might fail. Is there a next record? Maybe there are no more records in your recordset. I'm grasping at straws here as I really can't see the problem. I'm sorry.
Feb 28 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

15
by: Rey | last post by:
Howdy all. Appreciate your help with several problems I'm having: I'm trying to determine if the Visit subform (subformVisits) has a new record or been changed, i.e. dirty. The form that...
3
by: Cindy K. | last post by:
I'm using Access 2000, and have a continuous form with subtotals on the bottom of the form. The formula for the subtotal is =- The calcSum field is simply a Sum of a currency field in the form....
25
by: Lyn | last post by:
Hi, I am working on a genealogy form. The only table (so far) lists everybody in the family, one record per person. Each record has an autonum ID. The parent form (frmMainForm) displays the...
1
by: John Michael | last post by:
I have a form that has a subform that has a subform. The subform loads a record based on a combo lookup box in the main form. I'm trying to set a value in the subform based on a value in a...
4
by: Dave Boyd | last post by:
Hi, I have two very similar forms each with a subform. The main form gets a few fields from the user and passes this back to a query that the subform is bound to. The requery is done when the...
1
by: MP | last post by:
I have a main form that has a subform which also has a subform: the main form is the first subform is the second subform is When I click on the button »AddNewSubSubRecord« (add a new record...
1
by: lucazz | last post by:
I have a main form (not bound to any data source) with a subform based on a query. The subform shows furniture parts according to the criteria specified on the main form. The purpose of the subform...
6
by: DMUM via AccessMonster.com | last post by:
Hello I am trying to pass the name of my subform to a function/sub but I can't seem to get it to work. I am using an autokey function (ctrl E) to unlock text boxes on a subform. I have a few...
4
by: ramaswamynanda | last post by:
Hello All, This is my first question in this forum. I have a superform/subform design. When a value changes in the superform, a function is called which which calculate some values, and change it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
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...
0
Oralloy
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...

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.