Read and Insert RTF field

B

Biggles

I have distributed copies of my project databases. I am trying to import the
data from the ASSN_RTF_NOTES in the distributed copy into the master. If I
try to import the field, like this (some fields removed for space):

ssql(14) = "UPDATE MSP_ASSIGNMENTS " & _
"SET ASSN_UNITS = " & RS_ASSIGN_OLD!ASSN_UNITS & ",
" & _
... "ASSN_HAS_NOTES = " &
RS_ASSIGN_OLD!ASSN_HAS_NOTES & "," & v_ASSN_SSQL_END & _
"WHERE PROJ_ID = " & v_projid & " " & _
"AND TASK_UID = " & v_TASK_ID & " " & _
"AND RES_UID = " & RS_ASSIGN_MAST2!RES_UID

Where:
v_ASSN_SSQL_END = v_ASSN_SSQL_END & ", ASSN_RTF_NOTES = " &
RS_ASSIGN_OLD!ASSN_RTF_NOTES & " "

If I try to see the value of v_ASSN_SSQL_END In the immediate window I get:

?v_assn_ssql_end
EXT_EDIT_REF_DATA = '1,0.946745562130178,5/12/2008 8:00:00 AM,5/23/2008
5:00:00 PM,76500,0,,,0,4800000,4800000,4800000,,,' , ASSN_RTF_NOTES =
??????????????????????????????????????‰????????????????????????????????????????????????????

The value in the Notes field of this assignment is "Michigan market Work"
and if I use this function:

v_RTF = StrConv(RS_ASSIGN_OLD!ASSN_RTF_NOTES, vbUnicode)

I get:

?v_rt
{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss\fprq2\fcharset0 Arial;}}
{\*\generator Riched20 5.50.99.2010;}\viewkind4\uc1\pard\f0\fs16 Michigan
market work\par
}

But I don't know what to do with it.
 
R

Rod Gill

Hi,

Which version of Project? If 2007 then you have a problem in that Microsoft
no longer supports working with the db directly, so do not publish a schema
and they reserve the right to change the schema for any hotfix and SP. If
2003 or earlier then look at the pjdb.htm file in one of Project's program
folders for information. Make sure you get those flags correct. In fact
getting anything wrong can corrupt the project.

--

Rod Gill
Microsoft MVP for Project

Author of the only book on Project VBA, see:
http://www.projectvbabook.com
 
B

Biggles

Rod

I am using 2003 (and hope to stay that way for a while), and I reviewed the
PJDB.htm, but I guess I don't understand this part

Sub writeRtf()
'This macro writes RTF data to MSP_TASKS.TASK_RTF_NOTES.

Dim cn As New ADODB.Connection
Dim cmd As New ADODB.Command
Dim param As New ADODB.Parameter
Dim sql As String, rtf As String, cnString As String

cnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=c:\temp\MyProject.mpd"
sql = "update MSP_TASKS set TASK_RTF_NOTES = ? where PROJ_ID = 1 and
TASK_UID = 1"
rtf =
"{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss\fcharset0
Arial;}}" & vbNewLine & _
"\viewkind4\uc1\pard\f0\fs20 What's in a name? That which we call
a rose... \par" & vbNewLine & _
"}" & vbNewLine & vbLf & Chr(0) 'be sure to specify valid RTF
text here including "vbLf & Chr(0)

cn.Open cnString

param.Direction = adParamInput
param.Type = adVarBinary
param.Size = 8000
param.Value = StrConv(rtf, vbFromUnicode)

cmd.ActiveConnection = cn
cmd.CommandText = sql
cmd.Parameters.Append param
cmd.Execute
End Sub

If I can get :What do I have to do to write it to the new master table, what do I need in
my SSQL?

"SET ASSN_RTF_NOTES = " & ???????????
 
B

Biggles

Rod,

As I think about it, why do I have to convert the data at all? I am copying
information from one ASSN_RTF_NOTES field to another, isn't there an easier
way?
 
R

Rod Gill

Hi,

I don't know as I haven't played with the database directly for a while
(Project 2007 doesn't let you!). Either copy using VBA or I'm afraid you
have to play with the fields and see what happens. RTF is not
straightforward as you've already seen!

--

Rod Gill
Microsoft MVP for Project

Author of the only book on Project VBA, see:
http://www.projectvbabook.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top