Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Import csv error - Record is deleted

Posted on 2009-04-08
11
Medium Priority
?
495 Views
Last Modified: 2013-11-28
Greetings,
I have a button that first deletes all records from 5 tables, then imports data using csv files.  I get the runtime error 3167 - Record is deleted that points to the Me.Requery line in the code.

The data are in the tables as they should be, but the controls all show #deleted#

The odd thing is, if I just bypass the error (click END) and rerun this, it all works OK.
Private Sub cmdImportMDB_Click()
'Turn off the warnings
DoCmd.SetWarnings False
'Provide data overwrite warning
response = MsgBox("Are you sure you want to OVERWRITE the existing data?", vbOKCancel, "Import Species List")
If response = 1 Then
DoCmd.RunSQL "DELETE FROM WetForm"
DoCmd.RunSQL "DELETE FROM WetVeg"
DoCmd.RunSQL "DELETE FROM WetHyd"
DoCmd.RunSQL "DELETE FROM WetSoil"
DoCmd.RunSQL "DELETE FROM SpeciesLookup"
DoCmd.TransferText acImportDelim, , "WetForm", "C:\WetForm\WetFormExport.csv", True
DoCmd.TransferText acImportDelim, , "WetVeg", "C:\WetForm\WetVegExport.csv", True
DoCmd.TransferText acImportDelim, , "WetHyd", "C:\WetForm\WetHydExport.csv", True
DoCmd.TransferText acImportDelim, , "WetSoil", "C:\WetForm\WetSoilExport.csv", True
DoCmd.TransferText acImportDelim, , "SpeciesLookup", "C:\WetForm\SpeciesLookupExport.csv", True
MsgBox "WetForm, WetVeg, WetHyd, WetSoil, SpeciesLookUp successfully Imported", vbOKOnly
Else
End If
Me.Requery ' This is where the error points to
DoCmd.SetWarnings True
End Sub

Open in new window

0
Comment
Question by:phmurphy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
11 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 24097279
try moving the Me.Requery after the MsgBox



MsgBox "WetForm, WetVeg, WetHyd, WetSoil, SpeciesLookUp successfully Imported", vbOKOnly

Me.Requery '

Else
End If

DoCmd.SetWarnings True
End Sub
0
 

Author Comment

by:phmurphy
ID: 24097357
I get the same error.  It is odd that just by running it a second time it works OK, and all subsequent runs are OK too.
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 24097488
what is the recordsource of the form?
0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 

Author Comment

by:phmurphy
ID: 24097517
The table WetForm is the mainform and the other Wet... tables are subforms, and Specieslookup is a lookup table.
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 24097639
try, instead of me.requery

me.recordsource="select * from wetform"

see if it makes a difference
0
 

Author Comment

by:phmurphy
ID: 24097817
Exact same error.  Same result (no error) when reruning the same routine a second time.
I also tried me.refresh.
Here is what the help info is on the error

Record is deleted. (Error 3167)
You referred to a record that you deleted or that another user in a multiuser environment deleted. Move to another record, and then try the operation again.

Perhaps I need to do something to the tables after I delete all the records?

 
0
 

Author Comment

by:phmurphy
ID: 24098183
It seems as if the first time I run the routine it puts the tables to "sleep", and when I run it a second time it wakes them up.
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 24098891
do you need to run this importing of new data on this form?

can you tell more of the process you are doing?
0
 

Author Comment

by:phmurphy
ID: 24098969
Yes I do need to use the csv import.

What I am doing is exporting and importing a csv file that will be used/edited on a PDA.  Using sync software is so glitchy and unreliable I just prefer doing it this way.  The tables are just fine during the import, the form is just having a hard time with it.  As I was saying, if I just ignore the error and run the import a second time, it works fine from then on.  I can export and import multiple times with no error.
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 2000 total points
ID: 24099036
<Yes I do need to use the csv import.> Do you have to use this form for importing the CSV?

or we can trap the error then just clear it..


'error handling codes

on error goto ImportEH





ImportEH:
      if err.number=3167  then
         err.clear
         resume next
     end if

0
 

Author Closing Comment

by:phmurphy
ID: 31568032
Sorry it took so long.
0

Featured Post

What Is Blockchain Technology?

Blockchain is a technology that underpins the success of Bitcoin and other digital currencies, but it has uses far beyond finance. Learn how blockchain works and why it is proving disruptive to other areas of IT.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

661 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question