473,395 Members | 1,452 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,395 software developers and data experts.

Error with Do Loop while trying to validate ranges in a table

Hi All,

I am working on a sub that will loop through a recordset and validate
that the ranges are valid, ie no overlapping values - no gaps in the
ranges. I am pretty sure I have the validation part right but not
sure since I keep getting an error message "Compile Error: Loop
without Do". Of course I have a Do in the code and have looked at the
help files to see what is wrong with my syntax and I don't see the
problem.

Will someone please take a look at my code and see if you can tell me
what I am doing wrong? Thanks to all in advance!!!!

*********begin code****************
Dim db As Database
Dim rst As DAO.Recordset
Dim cur_group_id As Integer, cur_range_id As Integer, cur_range_begin
As Integer, cur_range_end As Integer, Valid_range_begin As Integer
Dim prior_group_id As Integer, prior_range_id As Integer,
prior_range_begin As Integer, prior_range_end As Integer

Set rst = CurrentDb.OpenRecordset("SELECT
Local_market_score_group_member_range.mkt_score_gr p_id as group_id,
Local_market_score_group_member_range.range_id as range_id,
Local_market_score_group_member_range.range_begin as range_begin,
Local_market_score_group_member_range.range_end as range_end FROM
Local_market_score_group_member_range ORDER BY
Local_market_score_group_member_range.mkt_score_gr p_id,
Local_market_score_group_member_range.range_id; ", dbopensnapshot)

prior_group_id = 0
prior_range_id = 0
prior_range_begin = 0
prior_range_end = 0

rst.MoveFirst
cur_group_id = rst![group_id]
cur_range_id = rst![range_id]
cur_range_begin = rst![range_begin]
cur_range_end = rst![range_end]

Do Until rst.EOF
If cur_group_id > prior_group_id Then 'new group - reset "prior"
variables
prior_range_id = 0
prior_range_begin = 0
prior_range_end = 0

Else ' We are still looking at the same group so begin validating
ranges
If cur_range_end > cur_range_begin Then
MsgBox "Range end must be greater or equal to range begin"
Exit Do
Else ' Current range values are valid so check that current range
begin is prior_range_end + 1
Valid_range_begin = (prior_range_end + 1)
If cur_range_begin <> Valid_range_begin Then
MsgBox "Current Range Begin value is either less than prior
Range end or there is a gap in the range values."
Exit Do
End If
prior_group_id = rst![group_id] ' resets the group_id
variable to the current record
rst.MoveNext
Loop

*********end code************

Thanks again,
Loribeth
Nov 12 '05 #1
2 3498
You're missing a couple of "End If" lines. You need one for each
"If".
On 9 Sep 2003 13:15:28 -0700, lp*********@insweb.com (Loribeth) wrote:
Hi All,

I am working on a sub that will loop through a recordset and validate
that the ranges are valid, ie no overlapping values - no gaps in the
ranges. I am pretty sure I have the validation part right but not
sure since I keep getting an error message "Compile Error: Loop
without Do". Of course I have a Do in the code and have looked at the
help files to see what is wrong with my syntax and I don't see the
problem.

Will someone please take a look at my code and see if you can tell me
what I am doing wrong? Thanks to all in advance!!!!

*********begin code****************
Dim db As Database
Dim rst As DAO.Recordset
Dim cur_group_id As Integer, cur_range_id As Integer, cur_range_begin
As Integer, cur_range_end As Integer, Valid_range_begin As Integer
Dim prior_group_id As Integer, prior_range_id As Integer,
prior_range_begin As Integer, prior_range_end As Integer

Set rst = CurrentDb.OpenRecordset("SELECT
Local_market_score_group_member_range.mkt_score_g rp_id as group_id,
Local_market_score_group_member_range.range_id as range_id,
Local_market_score_group_member_range.range_beg in as range_begin,
Local_market_score_group_member_range.range_end as range_end FROM
Local_market_score_group_member_range ORDER BY
Local_market_score_group_member_range.mkt_score_g rp_id,
Local_market_score_group_member_range.range_id; ", dbopensnapshot)

prior_group_id = 0
prior_range_id = 0
prior_range_begin = 0
prior_range_end = 0

rst.MoveFirst
cur_group_id = rst![group_id]
cur_range_id = rst![range_id]
cur_range_begin = rst![range_begin]
cur_range_end = rst![range_end]

Do Until rst.EOF
If cur_group_id > prior_group_id Then 'new group - reset "prior"
variables
prior_range_id = 0
prior_range_begin = 0
prior_range_end = 0

Else ' We are still looking at the same group so begin validating
ranges
If cur_range_end > cur_range_begin Then
MsgBox "Range end must be greater or equal to range begin"
Exit Do
Else ' Current range values are valid so check that current range
begin is prior_range_end + 1
Valid_range_begin = (prior_range_end + 1)
If cur_range_begin <> Valid_range_begin Then
MsgBox "Current Range Begin value is either less than prior
Range end or there is a gap in the range values."
Exit Do
End If
prior_group_id = rst![group_id] ' resets the group_id
variable to the current record
rst.MoveNext
Loop

*********end code************

Thanks again,
Loribeth


Nov 12 '05 #2
Not sure why I need to use End If instead of Else but I made the change.
Replaced the instances of Else with End If.

Now when I try to run I get a message that just says "Overflow". I
tried to check my help files and the word "overflow" shows up in the
index but when I click on it nothing happens(this is not the only topic
that behaves like this). Can anyone please help with

1. What does the "overflow" message mean?

2. Why can I see some of the help files and not others?

Thanks so much!!!

Loribeth

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

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

Similar topics

2
by: Phil Powell | last post by:
I am not sure why this is producing a SQL Server related error, but w/o having an instance of SQL Server on my machine to verify anything further, can you all help me with this? <!--- validate()...
6
by: Dave | last post by:
I have to automate a process that assigns sales leads to sales people. For example: Every day we buy a list of sales leads, it ranges in size from 50 - 100 records. We have a team of sales...
6
by: ALthePal | last post by:
Hi, I'm not sure if we are able to or even how to loop through the web forms in a VB.NET project during design time. In MSAccess we are able to go through the database -> forms collection and...
1
by: Beau | last post by:
Hi all, thanks in advance. Ok, heres the story. What is happening...... -------------------------------- I've got an ASP page that loops. It loops in order to get data in different,...
5
by: Doslil | last post by:
I am trying to validate a text field where the user has to input the first name I am writing the following function Private Function EFN() On Error GoTo EFNErr If IsNull(Me.FirstName) Or...
7
ak1dnar
by: ak1dnar | last post by:
Hi, I got this scripts from this URL There is Error when i submit the form. Line: 54 Error: 'document.getElementbyID(....)' is null or not an object What is this error. Complete Files
0
by: forgedascendant | last post by:
Good day everyone, I am new to this site so please forgive me if this post isn't completly correct. For the past 2 weeks I have been beating my head against the wall trying to figure out what is...
1
by: FightClubDiego | last post by:
Hey.. I've been working on these sign up / log in forms for my new Game Site, and everything else in the game works but the registration!! I keep ketting the unexpected $end and Im tired of it! Here...
2
by: vijayrvs | last post by:
SearchCrawler.java The program search crawler used to search the files from the website. From the following program i got 7 compiler error. can any body clarify it and provide me solution. ...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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...

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.