473,511 Members | 15,715 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Looping an OnError until duplicate error clears.

5 New Member
Ok, this may not even be possible, but I have to ask if anyone can think of anything. Searches have come up empty.

What I am trying to do in a form is after updating a customerID field, the next field CustomerEntry# populates with a 1. Easy enough.

The issue is that these 2 #'s combined form a unique ID in the table, so I want to make it so if the runtime error for duplicates comes up, it goes to the error handler and adds one to the value, then rechecks for duplicates again, and if the error occurs, try again, etc until there is no duplicate anymore.

Because the duplicate is in the table, not the form, I need to refresh the form to get the desired error. I have successfully got it to loop through once, changing the answer to 2, but after that the OnError doesn't seem to work and the error pops up with the form refreshes again.

I appreciate any ideas people might have. I'm a novice with OCD which is a bad combo ;) After 3 hours of failing I decided to stop trying and seek advice. Thanks to all.
May 27 '16 #1
8 1479
PhilOfWalton
1,430 Recognized Expert Top Contributor
Please let us see your table structure. It doesn't look too good.

Phil
May 27 '16 #2
Keithg1229
5 New Member
The database is at work I will have to wait a few days. Thanks for getting back. The table is a bear I created it years back when I had no idea what I was doing.
May 28 '16 #3
NeoPa
32,557 Recognized Expert Moderator MVP
KeithG:
I'm a novice with OCD which is a bad combo ;)
On the contrary. Software and database design is a perfect fit for OCD!

In this case you may want to consider checking the table first to determine what is the maximum value already in use. Here's (Item Numbering Within a Group) an article that points the way. A different, but quite similar, use case shouldn't put you off. Let us know if you struggle with it.

OTOH. With reference to re-using OnError code ever, it helps to understand that once an error has triggered this code, the error state is such that it knows it's in an error state. That is, until any form of Resume is used.

So, Resume or Resume Next will allow the OnError statement to be re-instated. Using any other way to loop through to your code will ensure it is still in error mode so the OnError won't be active. I hope that makes sense.
May 28 '16 #4
Keithg1229
5 New Member
Thanks so much, I will read this linked info and give it a whirl. Also thanks for the info about On Error I did not know that!
May 29 '16 #5
Keithg1229
5 New Member
Ok I came up with a completely different way to do this using DCount and an unbound text field that equals the ID# for the criteria.

Thanks guys for getting back to me :)
May 29 '16 #6
NeoPa
32,557 Recognized Expert Moderator MVP
Hi Keith.

That approach (if I understand you correctly) will work up to a point. It does assume that none of the records are missing from the list and that all existing records within the specified grouping are numbered sequentially from one to the maximum number used.

In my experience that is not a safe thing to rely on. DMax() does a much more reliable job for you.

Good thinking though ;-)
May 30 '16 #7
Keithg1229
5 New Member
I didn't think to try that. I will play around with it. Thanks for the suggestions :)
May 30 '16 #8
NeoPa
32,557 Recognized Expert Moderator MVP
KeithG:
I didn't think to try that.
It was at the heart of the article I linked to in post #4. If you haven't read that yet I recommend you do. There are a number of gotchas involved that it will help you avoid.

Good luck.
May 30 '16 #9

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

Similar topics

5
5119
by: S.Patten | last post by:
Hi, I have a problem with updating a datetime column, When I try to change the Column from VB I get "Incorrect syntax near '942'" returned from '942' is the unique key column value ...
2
6107
by: Robert Oschler | last post by:
If I set window.onerror to an error handler I've created, I don't see the browser error dialogs anymore but I don't see the alert() messages in my error handler pop up either. Can someone tell me...
1
3706
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,...
13
2819
by: lithoman | last post by:
I'm stumped here. I run the procedure Batch_Select against the database with @ID=18 and I get the expected data. When it loads into a SqlDataReader, it gets messed up somehow. Initially, after the...
1
2967
by: bruce24444 | last post by:
I am designing a database to use a work to assign files to certain people. Form includes Date textbox, File Number textbox, File Type combobox and Assigned To combobox. The form is working fine and...
4
4964
by: SJ | last post by:
Hi! I am trying to do a simple udpate on a table and I am getting the error: "Cannot insert duplicate key row in object 'UserInfo' with unique index 'UserInfo_Login'.The statement has been...
1
1998
by: UT-BadBoy | last post by:
Hi, I've been receving this error "System.InvalidOperationException: The namespace, , is a duplicate." and have been unable to locate the exact cause of the exception. I've written a...
2
2565
by: raphael001 | last post by:
In my Visual Basic program I'm just trying to find duplicate values entered into an array from an inputbox, but i can't seem to get the coding right on the final part to check for duplicate values...
8
3111
by: zyzolus | last post by:
Hello, I create 2 unique indexes on 2 fields: Field1 and Field2. What is the way generate custom error message independent of each field?ex.: "Duplicate value in Field1" or "Duplicate value...
1
7120
by: jsungmin | last post by:
hye. I have a little problem about loopping statement. This is the code.. <cfloop query="getQuest"> <cfset count=0> <cfquery name="chechking" datasource="#ds#"> select status_flag...
0
7251
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
7430
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
5673
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,...
1
5072
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...
0
4743
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...
0
3230
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...
0
3217
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
790
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
451
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...

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.