We help IT Professionals succeed at work.

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

podoboq
podoboq asked
on
Medium Priority
726 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!
Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2006

Commented:
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
CERTIFIED EXPERT
Top Expert 2006

Commented:
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

Author

Commented:
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?

Author

Commented:
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
CERTIFIED EXPERT
Top Expert 2006

Commented:
The pack should be on the CD, office CD I believe
u might even be able to download from the MS website

Author

Commented:
okay, anyone?
CERTIFIED EXPERT
Top Expert 2006

Commented:
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.

Author

Commented:
>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.
CERTIFIED EXPERT
Top Expert 2006

Commented:
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



Author

Commented:
ok, how to pass the path to the table as an argument?
CERTIFIED EXPERT
Top Expert 2006

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

sDB is the variable

Author

Commented:
I mean, how to execute the macro with the path to the table as a command line argument. Is this possible?
leclairm.Net Developer  ERP integration

Commented:
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\"
CERTIFIED EXPERT
Top Expert 2006

Commented:
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
CERTIFIED EXPERT
Top Expert 2006

Commented:
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 ?

Author

Commented:
ekhem, really sorry, when I said VB, I meant VBA. Shall this work with VBA as well?
CERTIFIED EXPERT
Top Expert 2006

Commented:
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

CERTIFIED EXPERT
Top Expert 2006

Commented:
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
CERTIFIED EXPERT
Top Expert 2006

Commented:
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

Author

Commented:
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.
CERTIFIED EXPERT
Top Expert 2006
Commented:
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


Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.