Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error 3011 - Timing Issue 1

Status
Not open for further replies.

lollyjar

Programmer
Aug 3, 2003
29
GB
I am programatically doing the following (in MSAccess97):
1. creating a table
2. populating the table by importing from a text file
3. updating a field in the table

For some reason, I am getting the Run-time error '3011' (table cannot be found) within the third step. If I choose the debug option, wait for a second then continue the code execution by hitting play again, the code finishes and succesfully updates the table.

It appears that although the table has been created and populated before the third step the table still appears not to exist. By waiting a second the newly created table becomes visible (or appears to exist) and the code continues as desired.

Can anyone explain what is happening and how to avoid it?

Cheers.
 
lollyjar

You probably have a typo in your progam.

Consider putting a STOP statement in your VB code, and use F8 to step through the code. You can hover the mouse over a variable to see the value currently in memory, and use the immediate window (CTRL-G) to test statments and logic.

The only "gotcha" here is if you hit the error and have error condition statment somewhere in the stack, the error routine will be called. So you have to look at the statement before the error, and figure out the next statment that would have been executed, and deduce what caused the error.

Richard
 
Thanks for the idea Richard, however if I use F8 to step through the code, I do not get the error at all.

I think this is because by using F8, there is enough time for the table to be recognized as existing, therefore no error occurs.

Any further thoughts?

Cheers
 
I have encountered similar timing problems, where the database has not completed its previous operation, and you need to give it more time to complete. My workaround for the problem is to trap the error, return control to the OS, and then retry the operation.
Code:
Private Sub Form_AfterDelConfirm(rInt_Status As Integer)

   On Error GoTo Error_Handler
   
   fBol_StartDelete = False
   DoEvents
   DoCmd.GoToRecord , , acFirst

Exit_Form_AfterDelConfirm:
Exit Sub

Error_Handler:

   Select Case Err.Number
      Case ERR_DEL_NOT_DONE_YET ' 2105 (Defined as Symbolic Constant)
         DoEvents
         Resume
      Case Else
         ErrMessage vbNullString, (Me.Name & ".Form_AfterDelConfirm")
         Resume Next
   End Select

End Sub
In my case is was after a record deletion operation, and the error code was 2105. You may be getting a different error code, but you can use the same technique.


Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Hmmm
I never saw this specifc problem but it makes sense in a network environment or on a larger, heavily indexed table.

Yet another star for you and a few others in this forum are more than just "retty good"... Too bad you can't cash in the stars you have earned for air miles, or something.
 
Thanks for the workaround.

On thinking about it overnight however, I decided to leave the table permanently, and just deleted all records before re-populating it. As a result, I dont get the problem of the table not existing. An intriguing problem though!

If anyone understands the way that Access knows if the table exists, I would be interested to find out.

Cheers
 
just a thought : if you are using DAO to create the table structure, do you use the Db.Refresh method after creating the table ?
 
lollyjar said:
If anyone understands the way that Access knows if the table exists, I would be interested to find out.
You might start by investigating the Application.CurrentData.AllTables collection.

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top