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.
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.
8 1473
Please let us see your table structure. It doesn't look too good.
Phil
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.
NeoPa 32,554
Expert Mod 16PB 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.
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!
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 :)
NeoPa 32,554
Expert Mod 16PB
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 ;-)
I didn't think to try that. I will play around with it. Thanks for the suggestions :)
NeoPa 32,554
Expert Mod 16PB 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.
Sign in to post your reply or Sign up for a free account.
Similar topics
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
...
|
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...
|
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,...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM).
In this month's session, the creator of the excellent VBE...
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: Aftab Ahmad |
last post by:
Hello Experts!
I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
|
by: Aftab Ahmad |
last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below.
Dim IE As Object
Set IE =...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: marcoviolo |
last post by:
Dear all,
I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
| |