Error messages 3734 or 3045

dmarop

Registered User.
Local time
Today, 06:47
Joined
May 17, 2013
Messages
41
Hello,

I use the following code to add data in the table MyTable. I am checking if exists and if is not exist i add it. Sometimes i take the error messages 3734 or 3045, that the database or the table are busy.

In the specific table write and read and other users.

Code:
If Nz(DLookup("[ID]", "MyTable", "[FirstName]= " & "'" & Trim(strTemp) & "'"), 0) = 0 Then
	CurrentDb.Execute "INSERT INTO MyTable ([FirstName]) VALUES (" & "'" & Trim(strTemp) & "');"
End If

What can i do?

Thank you in advance,

Dimitris
 
The important thing would be to handle any errors that the INSERT generates.

Code:
If CurrentDb.OpenRecordset("select id from MyTable where firstname='" & Trim(strTemp) & "'").EOF Then
	On Error Resume Next
	CurrentDb.Execute "INSERT INTO MyTable ([FirstName]) VALUES (" & "'" & Trim(strTemp) & "');"
	
	Select Case Err.Number
	Case 0 ' no error
        Case 3734,3045
	Case Else
		MsgBox "Insert failed" & vbnewline & Err.Description
	End Select
	On Error GoTo 0
End If

If the index is set properly a duplicate should be rejected and generate an error, so you actually don't need to check for uniqueness (the first IF), just handle any errors generated by the INSERT.
 
Thank you for your answer.

I want to ask something about the Case 3734,3045. When the code gives me these errors in Insert what will doing the code? It will try to add the data or will go to the next? I will lost the data?

In that case can you tell me what the code will do?

Regards,
Dimitris
 
Nothing would happen in my example because there is no code for those cases. (I didn't look up their meaning.)

Select case stops at the first match and executes the code following it...

Code:
Select Case Err.Number
	Case 0 ' no error
	Case 3734
		msgbox "OMG! Error 3734 has happened"
		Call RunToTheHillsAndBurryYourHeads(1)
	Case 3045 
		msgbox "OMG! Error 3045 has happened"
		Call RunToTheHillsAndBurryYourHeads(2)
Case Else
	MsgBox "Insert failed" & vbnewline & Err.Description
End Select
 
These kinds of error generally occur when the database is being used in a multi-user environment and it hasn't been split into a Front End (containing everything except the data...with a copy on each user's hard drive)/Back End (holding all Tables) configuration. Is that the situation, here?

Linq ;0)>
 

Users who are viewing this thread

Back
Top Bottom