If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Delphi, C etc > Open Database Error

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-04-03, 21:38
pjsgill pjsgill is offline
Registered User
 
Join Date: Oct 2003
Posts: 5
Open Database Error

Dear Friends

I m trying to import csv file into access table using vb code. It works for the first time, when 2nd time I try the same option I get the error message:

Run-time error '2075'

"This Operation Required an Open Database"

Here is the code

Dim dbs As Database
Dim rsttemp As Recordset
Dim rstmls As Recordset
Dim strdb2 As String
Dim appaccess As Access.Application

Set appaccess = CreateObject("Access.Application")
strdb2 = Dir1.Path & "\Prea.mdb" 'Main Database
appaccess.OpenCurrentDatabase strdb2

DoCmd.DeleteObject acTable, "mlstemp"
************************************************** *****
Error message comes at this line of the code
DoCmd.TransferText acImportDelim, , "mlstemp", selectedfile, 0
************************************************** ******
DoCmd.DeleteObject acTable, "datafile_mls_importerrors"
appaccess.CloseCurrentDatabase

Set dbs = OpenDatabase(strdb2)
Set rsttemp = dbs.OpenRecordset("mlstemp")
If rsttemp.EOF Then Exit Sub

Set rstmls = dbs.OpenRecordset("mls")
rstmls.Index = "PrimaryKey"
rsttemp.MoveNext
Do Until rsttemp.EOF
rstmls.Seek "=", rsttemp!F23
If rstmls.NoMatch Then
rstmls.AddNew
Else
rstmls.Edit
End If
updatemls rstmls, rsttemp
rstmls.Update
rsttemp.MoveNext
Loop
dbs.Close

Can anyone help me on this issue.

Thanks

Gill
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On