M
MAC
I have a table that contains a field 'rpt' with a data
type of OLE Object. I am trying to use VBA to assign it a
text file. I have also tried changing the data type of
the field to hyperlink but have run across the same
problems. Here is an example of my code
Dim stField1 as String
Dim intField2 as Integer
Dim stFileName as String
Dim obRpt as Object
Dim stDocName as String
Dim Conn as ADODB.Connection
Dim RS as New ADODB.Recordset
Dim DB as Database
Dim InFile as Integer
Dim InRec as String
InFile=FreeFile
Open \\ServerName\Archive\Dir.txt" as Input as #InFile
Input #InFile, InRec
stField1=left(InRec, 10)
intField2=CINT(mid(InRec, 11, 3))
stFileName=Trim(right(InRec,10))
Set DB=CurrentDB
Set Conn as New ADODB.Connection
With Conn
.Provider="Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "Data Source= " & DB.Name
.Open
End With
Set RS=New ADODB.Recordset
With RS
.CursorType=adOpenDynamic
.LockType=adLockOptimistic
.Open "Status_Rpts", Conn, , , adCmdTable
End With
stDocName= "\\ServerName\Archive\" & stFileName
'>>>This is where I have made several attempts at
assigning an Object to a variable
'>>>I Tried a direct assignment
obRpt=StDocName
'>>>I also tried
Set objRpt = GetObject(stDocName)
objRpt.SourceDoc = stDocName
objRpt.Action = acOLECreateEmbed
'>>>Nothing has worked.
With RS
.AddNew
![Field1]=strField1
![Field2]=intField2
![Rpt]=obRpt
.Update
End With
Set RS=Nothing
Set DB=Nothing
Conn.Close
While the Specs. Say that the Report should be in the DB,
I think they would be content with a link. I have been
working on this problem for some time and would appreciate
any help. Thanks
Michael Carrillo
type of OLE Object. I am trying to use VBA to assign it a
text file. I have also tried changing the data type of
the field to hyperlink but have run across the same
problems. Here is an example of my code
Dim stField1 as String
Dim intField2 as Integer
Dim stFileName as String
Dim obRpt as Object
Dim stDocName as String
Dim Conn as ADODB.Connection
Dim RS as New ADODB.Recordset
Dim DB as Database
Dim InFile as Integer
Dim InRec as String
InFile=FreeFile
Open \\ServerName\Archive\Dir.txt" as Input as #InFile
Input #InFile, InRec
stField1=left(InRec, 10)
intField2=CINT(mid(InRec, 11, 3))
stFileName=Trim(right(InRec,10))
Set DB=CurrentDB
Set Conn as New ADODB.Connection
With Conn
.Provider="Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "Data Source= " & DB.Name
.Open
End With
Set RS=New ADODB.Recordset
With RS
.CursorType=adOpenDynamic
.LockType=adLockOptimistic
.Open "Status_Rpts", Conn, , , adCmdTable
End With
stDocName= "\\ServerName\Archive\" & stFileName
'>>>This is where I have made several attempts at
assigning an Object to a variable
'>>>I Tried a direct assignment
obRpt=StDocName
'>>>I also tried
Set objRpt = GetObject(stDocName)
objRpt.SourceDoc = stDocName
objRpt.Action = acOLECreateEmbed
'>>>Nothing has worked.
With RS
.AddNew
![Field1]=strField1
![Field2]=intField2
![Rpt]=obRpt
.Update
End With
Set RS=Nothing
Set DB=Nothing
Conn.Close
While the Specs. Say that the Report should be in the DB,
I think they would be content with a link. I have been
working on this problem for some time and would appreciate
any help. Thanks
Michael Carrillo