Solved

How to convert Paradox Table into Access mdb file with VB?

Posted on 2006-10-25
21
492 Views
Last Modified: 2013-12-25
Being totally ignorant, I need a complete solution here:

A [VB] script, macro, program or whatever they call it, that can be run with a command line parameter - a path to Paradox table and afterwards open that very table. Essentially I need to programatically open a Paradox table as if I called File->Open within Access, set the filter to Paradox (*.db), selected the file and opened it. I noticed that whenever a Paradox table is open, MS Access creates a respective mdb file containing the data of the original table, so I suppose I just need to open the Paradox table in order to convert it to mdb.

Thank you!
0
Comment
Question by:podoboq
  • 12
  • 8
21 Comments
 
LVL 65

Expert Comment

by:rockiroads
Comment Utility
ok, I know u said VB, but as a alternative, here are some paid solutions

1) there is this s/w called ABC Amber Paradox Converter. That might help u. Convert your tables to csv then import this csv into MSAccess

2) A more expensive utility http://www.ozgrid.com/Services/sql-server-database-convert.htm
0
 
LVL 65

Expert Comment

by:rockiroads
Comment Utility
ok, yet another non command line alternative

I read somewhere that there is a builtin paradox converter that comes with Access. Its in the data access pack folder ValuPack\DataAcc
I dont know if this can be used on the command line or not


Now I dont have Paradox but can u try this

1. Install ODBC drivers and setup a DSN to your Paradox database
2. Use ADO or something to read the Paradox tables, then write that data into Access
0
 

Author Comment

by:podoboq
Comment Utility
well, ODBC is not an option for me, as well as ABC Amber Convertor (its a handy tool though). Where should I search for this data access pack folder?
0
 

Author Comment

by:podoboq
Comment Utility
Isnt there some simple way of calling Access with a macro name or something that just open a given paradox table?  I have to call this from within another program so command line or some other clever way of passing an argumant is a must
0
 
LVL 65

Expert Comment

by:rockiroads
Comment Utility
The pack should be on the CD, office CD I believe
u might even be able to download from the MS website
0
 

Author Comment

by:podoboq
Comment Utility
okay, anyone?
0
 
LVL 65

Expert Comment

by:rockiroads
Comment Utility
Was the converter on the office cd any good?

Pity u cant use ODBC as that would solve a lot of your problems I think.
0
 

Author Comment

by:podoboq
Comment Utility
>Was the converter on the office cd any good?
Well, i find this ValuPack\DataAcc for Office 97 on ms site but they dont mention any paradox cobverter.
0
 
LVL 65

Expert Comment

by:rockiroads
Comment Utility
ok, try this
how good is your ADO knowledge
Ive found a connection string that u may be able to use. I dont have Paradox so I cant test it
Ive then taken this connection string and built a simple loop, looping thru one table

Assumption: the database to be in C:\dbpath\



dim adoConn as New ADODB.Connection
dim adoRS as ADODB.Recordset


ON Error Resume Next

Err.Clear
'Note: There is an extra space after "db" in the Paradox Driver name, has to be that way
adoConn.Open "Driver={Microsoft Paradox Driver (*.db )};" & _
                      "DriverID=538;" & _
                      "Fil=Paradox 5.X;" & _
                      "DefaultDir=c:\dbpath\;" & _
                      "Dbq=c:\dbpath\;" & _
                      "CollatingSequence=ASCII"
if err.number <> 0 then
    msgbox "Connection Failure. " & err.Description
else
    set adoRS = New ADODB.Recordset
    adoRS.Open "SELECT * FROM somtable", adoConn, adOpenStatic, adLockPessimistic
    do while adoRS.EOF = False
        debug.print adoRS.Fields(0).Name, adoRS.Fields(0).Value
        adoRS.MoveNext
    loop
    adoRS.Close
    set adoRS = Nothing
    adoConn.CLose
end if
set adoCOnn = Nothing



0
 

Author Comment

by:podoboq
Comment Utility
ok, how to pass the path to the table as an argument?
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 65

Expert Comment

by:rockiroads
Comment Utility
adoConn.Open "Driver={Microsoft Paradox Driver (*.db )};" & _
                      "DriverID=538;" & _
                      "Fil=Paradox 5.X;" & _
                      "DefaultDir=" & sDB & ";" & _
                      "Dbq=" & sDB & ";" & _
                      "CollatingSequence=ASCII"

sDB is the variable
0
 

Author Comment

by:podoboq
Comment Utility
I mean, how to execute the macro with the path to the table as a command line argument. Is this possible?
0
 
LVL 11

Expert Comment

by:leclairm
Comment Utility
Yes it is possible.  Use the Command$ variable in vb.

Let's say your compiled code is ConvertTables.exe, you would call it like this:

c:\ConvertTables.exe c:\Paradox\Tables\

Now, in your vb code, Command$ will contain "c:\Paradox\Tables\"
0
 
LVL 65

Expert Comment

by:rockiroads
Comment Utility
As leclairm has said, use Command

here is a pictorial tutorial to help u
http://www.vbexplorer.com/VBExplorer/vb_feature/august2000/command_line_arguments.asp
0
 
LVL 65

Expert Comment

by:rockiroads
Comment Utility
And if u wanted multiple command line arguments, its easier if I just show u a link with code examples
http://www.codeguru.com/vb/gen/vb_misc/tips/article.php/c2735/

Now with u asking this, can I assume that the code I posted earlier about opening via ado is working ?
0
 

Author Comment

by:podoboq
Comment Utility
ekhem, really sorry, when I said VB, I meant VBA. Shall this work with VBA as well?
0
 
LVL 65

Expert Comment

by:rockiroads
Comment Utility
similar

In order to use command line parameters with MSAccess/VBA, u need to pass in using /cmd (http://support.microsoft.com/kb/209207)

Then in code u can use Command

0
 
LVL 65

Expert Comment

by:rockiroads
Comment Utility
Did that help then?

Did the ODBC connection to Paradox example code help you any?

Im guessing u are passing the name of the paradox database in

That example code, changed to using a variable

adoConn.Open "Driver={Microsoft Paradox Driver (*.db )};" & _
                      "DriverID=538;" & _
                      "Fil=Paradox 5.X;" & _
                      "DefaultDir=" & sDB & ";" & _
                      "Dbq=" & sDB & ";" & _
                      "CollatingSequence=ASCII"


Simply validate Command and set sDB to Command

sDB = Command

then try it
0
 
LVL 65

Expert Comment

by:rockiroads
Comment Utility
One question, u mentioned VBA, but question says VB
Are u using Access VBA?

If so then perhaps u could of used DoCmd.TransferDatabase

See this list as Paradox is a supported type

http://www.blueclaw-db.com/transferdatabase-docmd.htm
0
 

Author Comment

by:podoboq
Comment Utility
Thank you very much for your time and efforts, rockiroads! That sounds very helpful. Indeed, im using Access VBA. Probably this thread was not the best place to post this question in. Anyway, the only thing left is to code the macro itself:) Can I write a standalone script that does the conversion, or rather have some "database" open and attach the macro to it or what? Being quite unfamiliar with Access and VBA I'm somewhat confused and dont know how to start off.
0
 
LVL 65

Accepted Solution

by:
rockiroads earned 500 total points
Comment Utility
no probs

first I need to know what code u are planning to use?

If u want to use TransferDatabase and wish to use it in VBS, u can do something like this

    Dim acc
   
    Set acc = CreateObject("Access.Application")
    acc.OpenCurrentDatabase ("C:\EE\mydb.mdb")
    acc.DoCmd.TransferDatabase ...... THE REST OF THE LINE
    acc.CloseCurrentDatabase
    Set acc = Nothing



But first u need to verify that u can get TransferDatabase working

So if u can get whatever code u want working in VBA first, we then take it from there


0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

762 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now