G
Guest
OK, here's the long story:
I'm writing a Project Management application that I want to integrate with
Primavera. I want to be able to import Primavera data, save it into a table
in my database, allow users to work with it there, and then export it again
to Primavera. To do this, the Primavera file must be saved in DBF format,
which is no big problem, because Primavera can do that automatically.
The problem is, I don't want users to have to tell the application which
table to import to, and then have to programmatically allow them to link all
my forms to some new table they may have named arbitrarily. Instead, I'd
rather import the DBF data using a RunSQL command into a table I've already
created, designed for the purpose, and linked my forms to appropriately.
Therefore, I need a two-click system.
1) Select the DBF file to import from.
2) Import the data from the DBF file to my pre-made table.
I'm fairly certain the first option is easy. The second option is not (for
me). Here is my code so far...I'm starting slow, just trying to import the
Task name from the Primavera DBF file.
Dim objConn As ADODB.Connection
Dim objRS As ADODB.Recordset
Dim sPath As String, sFile As String, sSQL As String
Set objConn = New ADODB.Connection
Set objRS = New ADODB.Recordset
sPath = "C:\P3WIN\P3OUT"
sFile = "P3.DBF"
sSQL = "SELECT * FROM P3"
objConn.Open "Driver={Microsoft dBASE Driver (*.dbf)};" &
"DriverID=277;" & "Dbq=" & sPath '"Dbq=c:\somepath"
objRS.Open sSQL, objConn, , , adCmdText
Do While Not objRS.BOF And Not objRS.EOF
DoCmd.RunSQL "INSERT INTO tblPrimaveraDetail (
PD_ActivityDescription ) SELECT TITLE FROM objRS;"
Loop
The hard part is the RunSQL command, I believe. How do I tell it to select
it's data from the recordset I have created? Is this the best way to do it?
Does anyone have any comments or suggestions?
Thanks!
Dustin
I'm writing a Project Management application that I want to integrate with
Primavera. I want to be able to import Primavera data, save it into a table
in my database, allow users to work with it there, and then export it again
to Primavera. To do this, the Primavera file must be saved in DBF format,
which is no big problem, because Primavera can do that automatically.
The problem is, I don't want users to have to tell the application which
table to import to, and then have to programmatically allow them to link all
my forms to some new table they may have named arbitrarily. Instead, I'd
rather import the DBF data using a RunSQL command into a table I've already
created, designed for the purpose, and linked my forms to appropriately.
Therefore, I need a two-click system.
1) Select the DBF file to import from.
2) Import the data from the DBF file to my pre-made table.
I'm fairly certain the first option is easy. The second option is not (for
me). Here is my code so far...I'm starting slow, just trying to import the
Task name from the Primavera DBF file.
Dim objConn As ADODB.Connection
Dim objRS As ADODB.Recordset
Dim sPath As String, sFile As String, sSQL As String
Set objConn = New ADODB.Connection
Set objRS = New ADODB.Recordset
sPath = "C:\P3WIN\P3OUT"
sFile = "P3.DBF"
sSQL = "SELECT * FROM P3"
objConn.Open "Driver={Microsoft dBASE Driver (*.dbf)};" &
"DriverID=277;" & "Dbq=" & sPath '"Dbq=c:\somepath"
objRS.Open sSQL, objConn, , , adCmdText
Do While Not objRS.BOF And Not objRS.EOF
DoCmd.RunSQL "INSERT INTO tblPrimaveraDetail (
PD_ActivityDescription ) SELECT TITLE FROM objRS;"
Loop
The hard part is the RunSQL command, I believe. How do I tell it to select
it's data from the recordset I have created? Is this the best way to do it?
Does anyone have any comments or suggestions?
Thanks!
Dustin