In one of the sections i am running a query to delete all records in the db,
then a short while later i import the records intothe
DoCmd.OpenQuery "qryDelConfirmationTable", acViewNormal
DoCmd.TransferText acImportFixed, "alCouponSpecsImport2", "tblALConfirmFile", Filename
After that i attempt to build a new table wiht the current information, this returns a runtime error 3211, saying the database could not lock the table because it is in use.
I have read up on 3211 and the "solutions" did not help, i get the same thing. I tried closing the connection and redefining the connection same thing.
What am i doing wrong?
Expand|Select|Wrap|Line Numbers
- Private Sub CmdXLBrowse_Click()
- Dim Filename As String
- Dim db As Database
- Set db = CurrentDb()
- ' do things with db, not currentdb().
- Set db = Nothing
- 'Me.txtXLFIle = ""
- Me.txtXLFIle.Value = FindFile(Me.txtXLFIle.Value, "Please Select a Text File", "Text Files", "*.tx?")
- 'Me.txtXLFIle.Value = FindFile(Me.txtXLFIle.Value, "Please Select an Excel File", "Excel Files", "*.xl?")
- Filename = Nz(Me.txtXLFIle.Value, "1")
- 'Clean Up
- 'DoCmd.SetWarnings False
- DoCmd.OpenQuery "qryDelConfirmationTable", acViewNormal
- Debug.Print "Old Confirmations Erased"
- DoCmd.OpenQuery "qryDelCouponItemsTable", acViewNormal
- Debug.Print "Old Vouchers Deleted"
- DoCmd.TransferText acImportFixed, "alCouponSpecsImport2", "tblALConfirmFile", Filename
- 'Drop Table deletes from database
- 'CurrentDb.Execute "Drop table tblALConfirmFile"
- DoCmd.OpenQuery "qryALCreateCouponDataFile", acViewNormal
- DoCmd.OpenForm "frmALCoupon 7-24-08", acNormal
- 'DoCmd.SetWarnings True
- On Error GoTo MyErrorCheck
- MyErrorCheck:
- If Err.Number = 3011 Then
- ' Do something here
- MsgBox "Please Try Again", vbOKOnly
- Resume
- End If
- If Err.Number = 7874 Then
- ' Do something here
- Resume
- End If
- If Left(Trim(txtXLFIle), 1) = "'" Then
- ' comment line, skip it
- End If
- End Sub