On Error 2427 Handling

Mar 2, 2005

I have a form where the user enters a year then clicks on a command button to open a report.

If a year that there is no data for is entered an error 2427 occurs.

I have tried putting the following code in the on error event of the form with now success:

Select Case DataErr

Case 2427

MsgBox "There are no records for the year you entered" & Chr(13) & "Make sure you entered the correct year”

Response = acDataErrContinue
Case Else
Response = acDataErrDisplay

End Select


Does anyone know how to trap this error?

Thanks

View Replies


ADVERTISEMENT

Error Handling

Nov 23, 2006

I have recently upsized an Access database to SQL Server. The .adp is for the most part working fine.

However, when an end user tries to create a duplicate record in one of the Primary key columns of a Form he gets a SQL Server error message as follows:

"Violation of Primary Key constraint. Cannot insert duplicate key in object myTable".

This is obviously not a very useful error message. What would be the best way to ensure that a more useful error message is returned?

I have considered adding code to the "After_Update" event of the cell in question. This however seems long winded. Is there an easier option?

Thanks
Kabir

View 1 Replies View Related

Error Handling

May 12, 2005

Hi all

The following code only half works. I want to stop an ugly error occuring when primary keys are duplicated. In the following code the error handler picks up and displays a simple message when a user attempts to add duplicate values. BUT if the users adds a record, the record is successfully added followed with the same error message. I think I've put the error handler in the wrong place, but I can't figure out where it should go. Any ideas are much appreciated.

Damon

Private Sub cmdUpdateGoMaths_Click()
'update Go Maths

On Error GoTo error

Dim adors As ADODB.Recordset
Dim sSQL As String

' sSQL = "Select * from datGoMaths;"

' Set rsADO = New ADODB.Recordset
' rsADO.Open sSQL, CurrentProject.Connection, adOpenKeyset, adLockBatchOptimistic

sSQL = "dataGoMaths"
Set adors = New ADODB.Recordset
adors.Open sSQL, CurrentProject.Connection, adOpenDynamic, adLockOptimistic

With adors

.AddNew
.Fields("EQID") = Me.lstGoMathsStudentName
.Fields("IDGoMaths") = Me.lstUnitNo.Column(0)
.Fields("Score") = Me.txtScore

.Update

End With
Set adors = Nothing
MsgBox Me.txtStudentName & " Added"

Me.lstGoMathsStudentName = ""
Me.txtScore = ""

error:
MsgBox "test"
DoCmd.CancelEvent

End Sub

View 5 Replies View Related

Error Handling - Enough To Put In On Error Event

Sep 24, 2005

Every form has an on error property.

Is it enough for error handling to code the on error property for each form?
With enough I mean error handling which lets you resume the program.

Ontherwise I have to code (or call a procedure) for each coded event which i wouldn't prefer

For instance now I'm putting error handling in each event but would consider it more efficient if it can be placed once in each form
Private Sub cmdReport_Click()
On Error GoTo Err_cmdReport_Click

Dim stDocName As String

stDocName = "rptOfme"
DoCmd.OpenReport stDocName, acPreview

Exit_cmdReport_Click:
Exit Sub

Err_cmdReport_Click:
MsgBox Err.Description
Resume Exit_cmdReport_Click

End Sub

View 3 Replies View Related

Error Handling With Macro

Apr 30, 2006

I currently have a macro that sets the value of several fields on a "lost focus " event; however there is an error that I would like access to ignore, is there any way to have this macro process this function "On Error Resume Next" ?

Carbo

View 1 Replies View Related

Error Handling Problem

Aug 8, 2006

On a form i have a textbox to enter a date and multiple command buttons to open other forms.
After entering a date value, followed by either a tab or clicking on one of the command buttons, i want to validate the entered date value. If the date is invalid i want to display an error message and the cursor positioned on the textbox field.

The LostFocus event of the textbox is as follows:

Private Sub txtDateField_LostFocus()
If Not IsDate(txtDateField.Value) Then
MsgBox "Date invalid."
txtDateField.SetFocus
End If
End Sub

If entering an invalid date is followed by a tab, the error is displayed but the cursor is not positioned on the textbox field.
If entering an invalid date is followed by clicking on one of the command buttons, the error is displayed but the expected form is opened.
How to position the cursor appropriate and how to prevent opening the form?

Who helps?

View 1 Replies View Related

Error Handling Problem

Aug 8, 2006

On a form i have a textbox to enter a date and multiple command buttons to open other forms. After entering a date, either followed by a tab or clicking on one of the command buttons, i want the date validated. In case of an invalid date an error must be displayed and the cursor positioned to the textbox.
Therefor the LostFocus event is as follows:

Private Sub txtDateField_LostFocus()
If Not IsDate(txtDateField.Value) Then
MsgBox "Date invalid."
txtDateField.SetFocus
End If
End Sub

If entering an invalid date is followed by a tab the error is displayed but the cursor is not positioned to the textbox.
If entering an invalid date is followed by clicking on one of the command buttons the error is displayed but a form is opened.
How to position the cursor correctly and prevent opening of a form?

View 2 Replies View Related

Error-Handling Help Needed

Oct 25, 2006

How do you do an Access/VBE split screen? I want to be able to watch the code execute as I enter data into the form.

I have redesigned a database, essentially building a new one from scratch. I have all of the forms created and they are working beautifully. :) Now, I'm error-handling to create user-friendly messages. I have a superb Access programming book, but it only briefly mentions error handling and doesn't describe at all how to do it. Most of my forms are pretty simple, and I've been able to complete all of the error-handling tasks using the Form Error event as well as coding other events with the error message number. However, the main form is complex and includes a function in a standard code module and a custom sub routine.


TIA!
AA

View 2 Replies View Related

Error Handling When Report Cancelled

Oct 12, 2007

Just a quick one.

I'm not usre how to handle the error when cancelling a report. so when I hit a control to bring up a report and say I cancel it before I put in any parameters for example I get the dialog box " runtime error" "OpenReport action was cancelled" etc.

Could anyone help me on how to handle this with VBA so that it's at least a more user friendly dialog box?

thanks

View 3 Replies View Related

Modules & VBA :: Error Handling With Loop

Aug 6, 2015

I've got a problem with a loop for producing worksheets (reports). When everything works there's no problem but when one of the reports namely rptChemoOralWorksheet doesn't have data available to produce the report the loop finishes and then all remaining worksheets don't print.I've put in a standard error handler with MsgBox, but it's never triggered. I've also tried

Code:
On Error Resume Next

but again rather than skip the DoCmd.OpenReport "rptChemoOralWorksheet" (when the error is present) and move to the next one to continue printing through the list the loop stops and the subsequent code starts to run.

Code:
Dim mydatabase As DAO.Database
Dim rst As DAO.Recordset
Set mydatabase = CurrentDb
Set rst = mydatabase.OpenRecordset("atblChemoWSLoop", dbOpenDynaset)
Dim rsBN As String
Dim rsDose As Double

[code]....

View 4 Replies View Related

General :: Error Handling Query

Aug 28, 2012

I'm trying to split out the first name from a GivenNames field which contains first and middle names. Some values in the GivenNames field have just a first name. I've tried the below formula, but still get some #Error responses where only a first name exists in the field.

My formula:
Given Name: IIf(IsError(Left([GivenNames],InStr([GivenNames]," ")-1)),[GivenNames],Left([GivenNames],InStr([GivenNames]," ")-1))

View 2 Replies View Related

Dumb Question Of The Week - Error Handling

Apr 26, 2007

Do you folks include error handling in every single procedure?

Even on a "Quit" button with DoCmd.Quit behind it's OnClick event?

View 8 Replies View Related

Error Handling For ODBC Linked Tables

Jan 17, 2006

My tables are sybase linked tables to my Access front end. I get this error whenever i click away from my mainform while my not-null fields (textboxes) have not been entered. So, i would like to put an error message "somewhere" that tells the user to fill in the necessary fields and highlight the necessary textboxes in red, instead of this scary ODBC message
http://img82.imageshack.us/img82/6829/error0el.png :eek: :eek:

When i put my error handling in the afterUpdate or afterInsert Event. I still get the above error msg instead of my msgbox.
Where do i put this message? or should be question be, "what the proper way to handle this intimidating error? :)

Here's my error handling:

On Error GoTo Err_Form_AfterInsert

'do something


Exit_Form_AfterInsert:
Exit Sub

Err_Form_AfterInsert:
MsgBox Err.Description, vbExclamation, "Please enter the Project Name, Project Leader Initials, Main User and Status Code" & Err.Number
Me!Combo67.BackColor = "red"
Me!Combo65.BackColor = "red"
Me![Project Name].BackColor = "red"
Me![Project Leader Initials Combo].BackColor = "red"
Resume Exit_Form_AfterInsert


Thanks in advance for your help :D

View 14 Replies View Related

Error Handling When LostFocus Doesn't Work

Jun 7, 2006

Hi, hope somebody can help with this problem.

I have a med-large db shared on network. Am under some pressure to split front/back so more people can do data entry, but want the forms to be semi-finished before putting them on everybody's c:drive.

The problem is error handling for required fields. Some fields are required in the underlying tables because if users don't fill them in, reports are useless. But Access error msg for required fields are too strange, users just close down, maybe wrecking the thing. Don't want to eliminate Close button yet in case they get stuck in Access hell.

I got one ( !! ) field locked in well using LostFocus event, but what do you do if users just mouse into fields at random? LostFocus won't work if it never had focus, right?

(Would much prefer to just use unbound form and give choice of "Field is required" and "OK" or "Cancel this record" but realize that's asking for a lot of help here.)

Any assistance you can offer would be MUCH appreciated!! Vba course isn't until July.

Thanks,

View 9 Replies View Related

Modules & VBA :: Error Handling (label Not Defined)

Jan 12, 2014

I am studying error handling. I am using VBA Developers Hand Book and some Google stuff. I have been over the material several times and cannot find my mistake. When I click cmdFindState it give me "compile error" " label not defined",and stops at:

Code:
"On Error GoTo Err_cmdFindState_Click"

Code:
Private Sub cmdFindState_Click()
On Error GoTo Err_cmdFindState_Click
DoCmd.OpenForm "frmChurchesAll"
DoCmd.ApplyFilter "qryFindState"
'-----------------------------------------
' 51 Vermont
'------------------------------------------
DoCmd.GoToControl "ComboState"

[Code] .....

View 14 Replies View Related

Queries :: Error Handling In A Query That Was Run From A Macro

Aug 19, 2013

(I'm not sure if this belongs in the macro or query forum)

I have a macro that opens 15 queries and ends with opening a report.

The final query asks the user to type in beginning date, then an end date. Now when there's a data mismatch (i.e., he spells feburary), the macro halts. No harm no foul, they can just click the command button again, but I'd rather not.

What I'd like to do is place a msgbox (i.e., "Check Your Spelling") and then reroute them back to the query.

View 2 Replies View Related

Modules & VBA :: Error Handling / Loop / External Paths

Aug 14, 2014

I am setting up a form to send multiple attachments to an email.I have a query "qry_DwgEmail" that has an ID and a path column. On the form I have a button with the code below in the Click Event.The code below all works fine unless the path is incorrect, so I would like some error handling to be able to either:

1) Stop the code from running and display a message box with my message.
2) Continue the loop and then have the message box display what files could not be found (Preferred).

Note, the following code was taken from one of the forums I am not 100% on what it all means.

Code:
Private Sub btn_CreateEmail_Click()
Dim MyDB As Database
Dim MyRS As Recordset
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookAttach As Outlook.Attachment
Dim TheAttachment As String

[code]....

View 3 Replies View Related

Poor Error Handling In Access - It's Like Going Back In Time. Anyone Agree?

Sep 22, 2005

I'm sick of the lame excuse for error messages that Access gives out.. I'm talking about 'Overflow', 'invalid use of Null' and such like.

What about telling you what field/expression caused the error and on what record if applicable.

It's so frustrating - Access obviously knows what caused the error but refuses to tell you so you have to go through the annoying process of taking out fields one by one (when in query view).

Does anyone agree that they need to make the error handling in Access much better?

Thanks for any interest in my post.

View 4 Replies View Related

Modules & VBA :: Running Multiple Queries In A Routine - Error Handling

Oct 9, 2013

I am using access 2010. I use basic error handling in my routines:

Code:
On Error GoTo errHandler ... exitHere: ... errHandler: MsgBox "Error " & Err.Number & ": " & Err.Description

The problem is lately; while testing I am running multiple queries in a routine. When it fails; its hard to identify which query has the problem. So I hit control break; debug and try to find it. After I fix it; I debug and reset; i get this continuing hourglass thing in the form of a spinning circle until I close and reopen the database. I think I need better error handling but not something really complicated because I need to put it in quite a few routines throughout the database.

View 2 Replies View Related

General :: Handling Error Database Engine Cannot Find Record

Jul 8, 2013

how to deal with errors specifically with error "The Microsoft Access database engine cannot find a record in table".Database which I'm creating have table Products, which contains information about products. Most important information in this table is if product is VATable or not. I decided to define product names in invoice table that database can recognize products and calculate VAT in invoices if product is VATable. Problem starts if you have new product. When I add new product in invoice it counts VAT but when i go to next record I receive message mentioned above. It doesn't allows me to go to next record or save record.

I was wondering is it possible to make it that access allows to fill invoice, informs about new products only when i have finished adding all products in invoice and than gives opportunity to add them to product list?

View 1 Replies View Related

Problem With "on Error" Handling

Mar 29, 2006

In Microsoft Access 2002 I have a routine to add or edit an entry in a table. Because it is a multi user environment, there is a possibility, that someone else is currently editing the very same entry of the same table. Therefore I do an error handling with a message box appearing in case of an error to tell the user that this entry is currently locked. The user then has the choice of "cancel" or "retry". There is no problem with cancel, but if retry is selected, I repeat to edit the entry once more. Now, if the entry still is locked, I do not end of in the error routine again, and I get a runtime-error with the "update" command and exit the routine. It looks like the "on error goto Write_Err" command is ignored in the second go. Can anyone tell me what I did wrong? Here is the code I'm using:

Set ds = db.OpenRecordset("T_TeilResultate", dbOpenDynaset)
Temp = "((Fehlernummer = 1) AND (Resultat = " & ResultatID & "))"
ds.FindFirst (Temp)
If ds.NoMatch Then
ds.AddNew
ds!Resultat = ResultatID
ds!Status = 2 '2 entspricht FAIL'
ds!Fehlernummer = FLogID
ds.Update
ds.Bookmark = ds.LastModified
Else
'Es existiert ein Teilresultat mit Fehlerlog 1 das editiert wird'
Do
Writeok = False
'Form_F_NeueTeilresultate.RecordLocks = 2
ds.LockEdits = False
ds.Edit
ds!Status = 2
ds!Fehlernummer = FLogID
On Error GoTo Write_Err
'here is the problem if the loop runs twice!'
ds.Update
ds.Bookmark = ds.LastModified
ok = True
Writeok = True
Write_Err:
If Writeok = False Then
ds.CancelUpdate
Antwort = MsgBox("Table is currently locked!", vbRetryCancel)
If Antwort = vbCancel Then Writeok = True
ok = False
End If
Loop Until Writeok
End If


Thanks for any advice.
Walter

View 1 Replies View Related

Help With Text Handling

Dec 3, 2006

Hi

Have the following code that works on Access 2000

Dim myForenameBefore As String
Dim myForenameAfter As String
With CurrentDb.OpenRecordset("Names", dbOpenDynaset)
Do Until .EOF
myForenameBefore = .Fields("Forename")
myForenameAfter = Replace(.Fields("Forename"), "Elizh", "Elizabeth")
MsgBox myForenameBefore & " " & myForenameAfter
.MoveNext
Loop
.Close
End With

So that I can replace any abbreviated names in a table, however I cannot figure out how to put the value of myForenameAfter back into the table replacing the existing data.
Must be particularly thick today

View 5 Replies View Related

Message Handling

Oct 18, 2005

I have a form with a number of check boxes. Clicking on the checkboxes carries out a count function which is then displayed. If the count goes above 20 then a message box is displayed telling the user of it. My problem is that once the number is above 20, the message box diplays everytime. I want it to display just once, regardless of how high the number goes. The checkboxes can be ticked in any order.

At present i'm using

On click

If Me.Text1 > 20 Then
Msgbox "The number is graeter than 20"
End If

View 1 Replies View Related

Xml Formatting And Handling Of Keys

Jun 29, 2006

When I export my access database to XML I noticed that the XML elements for the table keys contain the key numbers themselves, not the table name (or a chosen field in the table). For an application I am working on, this presents a problem. What I have is:

One table called 'Process' that looks like:

Process instance_idSystem instance IdProcess name
26 24 Two_thread_process


I have another table called "Thread":

Thread _instance_id Process instance_Id Thread instance name
30 26 T1_instance


XML export looks like:

- <process_INSTANCE>
<process_instance_id>26</process_instance_id>
<system_instance_name_id>24</system_instance_name_id>
<process_instance_name>two_thread_process</process_instance_name>
- <thread_INSTANCE>
<Thread_instance_id>30</Thread_instance_id>
<process_instance_id>26</process_instance_id>
<thread_instance_name>T1_instance</thread_instance_name>
</thread_INSTANCE>
</process_INSTANCE>

What I would *like * the XML to look like is:

- <process_INSTANCE>
<process_instance_id>26</process_instance_id>
<system_instance_name_id>24</system_instance_name_id>
<process_instance_name>two_thread_process</process_instance_name>
- <thread_INSTANCE>
<Thread_instance_id>30</Thread_instance_id>
<process_instance_id>two_thread_process</process_instance_id> (**name instead of key here**)
<thread_instance_name>T1_instance</thread_instance_name>
<thread_instance_type>periodic</thread_instance_type>
</thread_INSTANCE>

The access XML export writes out the key values as they appear in the tables. What I would like is for it to put in the ‘process instance name’ instead of the key that points back to the base (process) field.
Any pointers on how I could do this?

Thanks
John

View 3 Replies View Related

Recommended Handling Of Images

Apr 12, 2007

Does anyone have a recommended way to deal with images (ie. linked to file, OLE object embedded, others I'm not aware of)???

I have a report which summarizes the history of a project. In this report I have a subreport which has task information. As a user enters task information they have the option of associating pictures with the task (ie. prototypes, design images, test setup, etc).

So my data structure is based on:
- many projects
- each project can have many tasks
- each task can have many pictures

My report for each project lists some typical project information and a subreport shows the task details associated with that project along with as many images that are associated with it.

My current system links to files on a network to avoid database size. This works well for storage and form use, until I try to print or preview a report. Then some of my pictures don't show up and I get a message that says images may be too large. My report could conceivably have up to 100 images, but I'm images stop showing up when I have around 15-20 pictures. Pictures files are typically 300 KB.

Is there a better way to show images on a report?????

View 6 Replies View Related

Handling Address Details

Apr 25, 2006

Hi All,
I am rather new to this and I must admit I am getting everything completely wrapped around my head!

I am developing a database that stores technical support requests received and their solutions. I have three main tables :

Problem - stores all the details of the problems received

Client - stores the address details of the client which is then associated with the 'Problem' table

Company - stores the name of the company which is then associated with the 'Client' table. This is a separate table as different clients can work for the same company.

At present, I have a 'problem data entry' form in which I enter all the details of the problem. At the top there is a section where I can do a search for a particular client and company and the details appear in the respective text boxs on the 'problem data entry' form. If the client does not exist, I have a button that I use to open another form which allows the entry of the new client's details ('New Client'). The user can choose which company this client works for by using a combobox. If the company is not already in the database, I have another button for opening a 'New Company' form!

Its all a little convoluted and it does not work particularly well to be honest. When I add a new company, I need to move forward a record and then back in the 'New Company' form in order that the new company information is saved correctly.

The company selection combobox in the form 'New Client' is then updated with the new company name BUT I need to actually open the combobox and select the company name myself for it to work properly! Once again I also need to move forward one record and then back again in order to properly save all the information before I can close the form.

What would be nice is to do a search for the the company in the combobox on the 'New Client' form, if the company is not found, it automatically adds the company to the database whilst updating all the necessary links. Hence getting rid of the 'New Company' form. I would also like to get rid of the problem of having to move forwards a record and then back again.

Any ideas? I find my method to be rather poor, there must be a simpler way of doing this!

Many Thanks,
Lee

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved