Code causing ocasional 3049?

mafhobb

Registered User.
Local time
Today, 15:19
Joined
Feb 28, 2006
Messages
1,249
I have a multiuser split db with this code on a listbox:
Code:
Private Sub lstsearch_DblClick(Cancel As Integer)

' The following is the variable definition for the error handler
    On Error GoTo lstsearch_DblClick_Error
    Dim ErrorForm As String
    Dim ErrorControl As String
    Dim ErrorCode As String
    Dim ErrorNumber As String
    ErrorForm = "SearchCustomer"
    ErrorControl = "lstSearchDblClick"

If IsNull(Me.lstsearch) Or Me.lstsearch.Value = "" Then
    MsgBox "Keinen Datensatz ausgewählt"
    Exit Sub
End If

    Dim stDocName As String
    Dim stLinkCriteria As String

' Procedure
    stDocName = "Contacts"
    stLinkCriteria = "[ContactID]=" & Me![lstsearch]
    DoCmd.OpenForm stDocName, , , stLinkCriteria
    Exit Sub
    
' Error handler
lstsearch_DblClick_Error:
    ErrorNumber = Err.Number
    ErrorCode = Err.Description
    Call SendError(ErrorCode, ErrorNumber, ErrorControl, ErrorForm)
    Exit Sub
End Sub

The error function sends me an e-mail listing the error, user, form and sub. Ocasionally some users get error 3049 when running this sub. It is generally one user out of about 10 or so and the db keeps working fine for everyone else. I have reviewed the back end several times and I cannot find any obvious corruption signs. I have compacted and repaired it several times with very small changes is size.

Can anyone see anything obvious in the code that could be causing this issue?

mafhobb
 
And what is the error description?
 
3049: "Cannot open database ''. It may not be a database that your application recognizes, or the file may be corrupt."

At this point, however, the user is logged in and the database is open already. Also, other users are logged in at the same time and they do not have any problems. If the user that is having problems logs off and logs back in then it is all fine.

mafhobb
 
I would comment out the error handling to get exactly which codeline cause the problem.
And I would take away the Value part!
Code:
If IsNull(Me.lstsearch) Or Me.lstsearch[B][COLOR=Red].Value[/COLOR][/B] = "" Then
I would suggest you to be more consistent and not use ! and . in a mix when you refer to a control!
Code:
If IsNull(Me[B][COLOR=Red].[/COLOR][/B]lstsearch) Or Me.lstsearch[B][COLOR=Red].[/COLOR][/B]Value = "" Then ... 
stLinkCriteria = "[ContactID]=" & Me[B][COLOR=Red]![/COLOR][/B][lstsearch]
And I don't like a lot of "Exit Sub", only one is necessary in your code. :)
 
I would comment out the error handling to get exactly which codeline cause the problem.

I have removed the ".value" part and modified the other line to get rid of the "!". I did not know that these could cause issues, but now I know and I'll try to be more consistent in the future. Thanks!

What do you mean, however by the statement above? I mean, other than using the debugger to figure out which line is causing the issue I do not know how to figure it out. And remember, this error happens ocasionally, not every time, and I have never seen it on my machine.

mafhobb
 
..
What do you mean, however by the statement above? I mean, other than using the debugger to figure out which line is causing the issue I do not know how to figure it out. And remember, this error happens ocasionally, not every time, and I have never seen it on my machine.

mafhobb
With the errorhandling on, you'll never get to know which codeline actually cause the problem - and to know which line of code is causing the problem is surely the first step to getting the problem resolved, or??
So I would comment out the error handling and tell the users to call/send a printscreen when they occasionally get an error, then you'll be able to see which line and can start a more targeted diagnostics.
But it is only my opinion/few cents.
 
maybe the form does not open correctly with the particular search entered. (although that ought to give a 2501, not a 3049). Maybe the error is caused within the form though, though? does that from have its own error handling? if not an error will bounce back here. maybe there are no results for the search term entered. would that produce a problem?

as you say, it is a curious error code.

do all users have separate front ends, or are you sharing the same front end?
 
Gemma-the-husky: The form has a textbox, a button and a listbox. A text string in entered in the textbox by the user and the button is used to search through the records and diplay them in the listbox. Then there is the double-click event in the textbox.

The form has an onload event (maximize) and an onclose envent. They all have their own error handling, which is identical (call function to save error in a table and to e-mail it to me). The only difference is the value for "ErrorControl", which is the name of the sub that is currently running and runs into the error. This way I know where the error is generated.

All users share one back end and have their own, identical front end.

JHB: I can try to create a numerical variable that adds "1" after each line of code that is run. Then, by retrieving the value of that variable I can find out how many lines run fine.

Dim Counter as Single
Counter=counter+1 after each line along with ErrorControl=ErrorControl & Counter

Then my error sub would tell me what line caused the problem
Is this crazy?

mafhobb
 
OK, so this is what I have done:
Code:
Private Sub lstsearch_DblClick(Cancel As Integer)

' The following is the variable definition for the error handler
    On Error GoTo lstsearch_DblClick_Error
    Dim ErrorForm As String
    Dim ErrorControl As String
    Dim ErrorCode As String
    Dim ErrorNumber As String
    ErrorForm = "SearchCustomer"
    ErrorControl = "lstSearchDblClick"
    
' Additional variable for troubleshooting
    Dim Line As String
    
    Line = "A"
    ErrorControl = ErrorControl & Line

'Check to see if the selection is empty or null
If IsNull(Me.lstsearch) Or Me.lstsearch = "" Then

    Line = Line & "B"
    ErrorControl = ErrorControl & Line

'If IsNull(Me.lstsearch) Or Me.lstsearch.Value = "" Then
    MsgBox "Keinen Datensatz ausgewählt"
    
    Line = Line & "C"
    ErrorControl = ErrorControl & Line
    
    Exit Sub
End If

Line = Line & "D"
ErrorControl = ErrorControl & Line

    Dim stDocName As String
    
Line = Line & "E"
ErrorControl = ErrorControl & Line

    Dim stLinkCriteria As String
    
Line = Line & "F"
ErrorControl = ErrorControl & Line

' Procedure
    stDocName = "Contacts"
    
Line = Line & "G"
ErrorControl = ErrorControl & Line

    stLinkCriteria = "[ContactID]=" & Me.lstsearch
    
Line = Line & "H"
ErrorControl = ErrorControl & Line

'    stLinkCriteria = "[ContactID]=" & Me![lstsearch]
    DoCmd.OpenForm stDocName, , , stLinkCriteria
    
Line = Line & "I"
ErrorControl = ErrorControl & Line
    Exit Sub
    
' Error handler
lstsearch_DblClick_Error:
    ErrorNumber = Err.Number
    ErrorCode = Err.Description
    Call SendError(ErrorCode, ErrorNumber, ErrorControl, ErrorForm)
    Exit Sub
End Sub

Now I should be able to see exactly what code has been run on this sub when the error comes up.

mafhobb
 
...Now I should be able to see exactly what code has been run on this sub when the error comes up.
Yes it should help you to find the code line.
Only a question - is it always the same user or in same company there get the error?
 
are you sure its not caused by the searchstring returning no records when the search is activated?

I am not sure why that would give you the error you get, but failing that, it's hard to see why you get any error at all.

I expect it will error at line "H".

Code:
 'Check to see if the selection is empty or null
If IsNull(Me.lstsearch) Or Me.lstsearch = "" Then

personally I would do this
Code:
 if nz(lstsearch,"")="" then
 
Gemma-the-husky, I have double-clicked on the listbox when the form just loads and no search has been performed and I have later performed a search with zero results. In both cases I get the message "Keinen Datensatz ausgewählt" (no valid selection made) but no error.

JHB, It is different users, although it is possible that they are on the same "side" of the building...perhaps there is an actual network problem?..if so, I am thinking that the error sub would not be able to record the error information on the table but it is.

mafhobb
 
Well, after much work on this issue and a couple of inconsistencies described in other threads, I created a new db and imported all the forms, queries, tables, etc to it.

Without any changes, the new db is 7Mb as opposed to 15Mb for the original. The problems described in other threads have dissapeared so it seems like I had some corruption issues somewhere. We'll see what happens with the error described here in the next few days.

mafhobb
 

Users who are viewing this thread

Back
Top Bottom