473,785 Members | 2,698 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Looping in a Subform

4 New Member
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 2161
Stewart Ross
2,545 Recognized Expert Moderator Specialist
...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.Previous Control.SetFocu s
DoCmd.GoToRecor d , , acFirst

Do While x > 1
Me.Check48 = True
DoCmd.GoToRecor d , , acNext
x = x - 1
Loop
When you say it errors before it starts to loop, is it when you execute the Docmd.GotoRecor d 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,578 Recognized Expert Moderator MVP
Can you tell us which line the error occurs on and what the error message is?
Feb 28 '08 #3
ccookson
4 New Member
the error occurs at the "DoCmd.GoToReco rd , , acNext"

I have added a save just before the DoCmd.GoToRecor d , , 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,578 Recognized Expert Moderator MVP
... and what the error message is?
Feb 28 '08 #5
ccookson
4 New Member
Sorry...

Run-time error '2105':

You cant go to the specified record
Feb 28 '08 #6
NeoPa
32,578 Recognized Expert Moderator MVP
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
24875
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 contains the subform is named Clients. I have this code in the Add Client btn: If Forms!Clients.subformVisits!VisitDirty = True Then MsgBox "Visit subform is dirty!"
3
2902
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. The unbFULL field is in the report header, filled when the form is opened through the OpenArgs property. I tried putting a conditional format on the field, stating that if the field value was greater than 0 to bold the field and shade the
25
10266
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 data in each record, which includes the ID of the father and the mother (who also have records in the table). One record per form. I have a Tab Control in the form, and in one of the tabs I have a subform (sfmSiblings) in which I wish to list...
1
8521
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 subform of the subform. the main Form is called Subform is called Subform in the subform is called
4
7018
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 user enters the last qualifying field on the main form. In one case this works fine, the subform shows the data the user wants to update -- which means showing all the data put in previously (ie showing this via the requery and the continuous...
1
3039
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 in the second subform , the code generates the message: Can't find the field »POG-03 Work Subform« reffrred to in your expression.
1
3768
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 is for user to enter produced quantities. To do this I've added a quan field to the subform that is not bound to any data. The problem is that whenever I enter a value in a record the same value appears in all the subform's records. The other way was...
6
5979
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 forms in the database that will use this function, so I need to be able to tell the code which form to unlock. What I have is as follows: Public Function akeyEdit()
4
9273
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 in every row in the subform. I am not able to figure out how to reach every row in the subform. What i need is i = subform.rowcount for count = 0 to i subform.field.value = calc_value next any help will be appreciated
0
9480
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10151
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10092
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,...
0
9950
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8973
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6740
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();...
0
5381
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...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2879
bsmnconsultancy
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...

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.