access error message instead of my own
access error message instead of my own
access error message instead of my own
access error message instead of my own
access error message instead of my own
access error message instead of my own access error message instead of my own access error message instead of my own access error message instead of my own access error message instead of my own access error message instead of my own access error message instead of my own access error message instead of my own
access error message instead of my own access error message instead of my own
access error message instead of my own
Go Back  Xtreme Visual Basic Talk > > > access error message instead of my own


Reply
 
Thread Tools Display Modes
  #1  
Old 12-21-2017, 10:31 AM
starmanMike starmanMike is offline
Junior Contributor
 
Join Date: Oct 2005
Location: near Norwich, UK
Posts: 310
Default access error message instead of my own


I want to check if the user is adding a record that already exists in the DB, so have an error handler (see below) but instead of my error message I get the runtime error 3022 within VB.
Code:
dyn.AddNew

'Place the necessary information in the recordset fields
On Error GoTo sorry
dyn.Fields(0) = frmDatabase.txtName.Text
'other entries go here...
'Use the update method to add the new record to the recordset
dyn.Update
...
Code:
exit sub
sorry:
Dim errorno As Long
errorno = Err.number
Select Case errorno
Case 3022
MsgBox "This star is already in the Database" & vbCrLf & "(maybe you want to edit its details instead?)", vbInformation, "No need for new record!"
Call blankoutboxes 'i.e., removes unwanted entries from textboxes
Case Else
Debug.Print errorno
End Select
But the code stops at dyn.update - surely it should just go to the 'go to'?
Reply With Quote
  #2  
Old 12-21-2017, 08:17 PM
Kluz's Avatar
Kluzaccess error message instead of my own Kluz is offline
Sapience.Aquire

Super Moderator
* Expert *
 
Join Date: Oct 2003
Location: Lake Bluff, Ill., U.S.
Posts: 3,467
Default

I would use a DLookUp before the erring line of code. If it returns a null then update the field.
__________________
No the other right mouse click
Reply With Quote
Reply

Tags
error, errorno, record, recordset, select, dyn.update, entries, message, edit, vbinformation, details, database, err.number, msgbox, star, vbcrlf, stops, code, surely, debug.print, i.e, blankoutboxes, call, removes, unwanted


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
access error message instead of my own
access error message instead of my own
access error message instead of my own access error message instead of my own
access error message instead of my own
access error message instead of my own
access error message instead of my own access error message instead of my own access error message instead of my own access error message instead of my own access error message instead of my own access error message instead of my own access error message instead of my own
access error message instead of my own
access error message instead of my own
 
access error message instead of my own
access error message instead of my own
 
-->