RTF2 CONTROL

J

John Thomas

I have data in subforms that I link using the following code as an example,
but RFT2, does support that property. Is there another way for me to do
this. It is basiclly groups of records in one field, identified by unique
matching codes in another in another. For example: the unique code of "1900"
would be the entire chapter of a book in the bible, representing all 25
verses in that chapter, all of which are each a separate record in another
field, and then display them in the RTF2 Control as a group.

This works in access subforms like I want it to for example:
Private Sub form2_Enter()
Me![form2].LinkChildFields = "unique chapter codes"
Me![form2].LinkMasterFields = "unique chapter codes"
End Sub

Thank you
 
S

Stephen Lebans

The Access ActiveX Host container only supports simple data binding, in
other words you can only bind the control to a single field.
YOu have a few options:
1) Set the RecordSource for the Form containing the control to a Query
containing the desired data.
2) Use a temp table with a single field bound to the control. Write all
of the relevant data to this field.
3) Use the control unbound instead of bound. Cocatenate all of the data
into a single string and then use this string to update the RTFText
property for the control.
--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
J

John Thomas

Thanks, I used the third option, that code is below, it seems to work ok,
the thing I need to do now is pass my treeview node selection to it. In the
code below I put in the WHERE number of 1800, any suggestions on passing the
node selection in its place. Any comments on my code below would be also
welcome.

Private Sub RTFControl1_Enter()
Dim DB As Database, RS As Recordset
Dim strSQL As String
Dim var1 As String
Dim var2 As String
Dim var3 As String
Set DB = CurrentDb

'Setup Query
strSQL = "SELECT * FROM [tblBible Text] WHERE [unique chapter
codes] = 1800"
Set RS = DB.OpenRecordset(strSQL)
'Get Book Name
var3 = RS!BookTitle

Do Until RS.EOF
'Get Chapter#, Verse# and Text and assemble string, add some rtf formatting
var1 = RS!Chapter
var2 = RS!Verse
var2 = " \par \par" & "{\cf1\super" & " " & var1 & ":" & var2 & " "
& "}"
'Build string
var3 = var3 & var2 & RS!KJV

RS.MoveNext
Loop

'Add rtf format to raw text
var3 = "{\rtf\ansi\ansicpg1252\deff0{\fonttbl{\f0\fnil\fcharset0 MS Sans
Serif;}}{\colortbl ;\red112\green112\blue255;}\viewkind4\uc1\pard" & var3 &
"}"
'Send to RTF2 Control
Me.RTFControl1.RTFText = var3
Set DB = Nothing
RS.Close
End Sub

Thanks again
Stephen Lebans said:
The Access ActiveX Host container only supports simple data binding, in
other words you can only bind the control to a single field.
YOu have a few options:
1) Set the RecordSource for the Form containing the control to a Query
containing the desired data.
2) Use a temp table with a single field bound to the control. Write all
of the relevant data to this field.
3) Use the control unbound instead of bound. Cocatenate all of the data
into a single string and then use this string to update the RTFText
property for the control.
--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.


John Thomas said:
I have data in subforms that I link using the following code as an example,
but RFT2, does support that property. Is there another way for me to do
this. It is basiclly groups of records in one field, identified by unique
matching codes in another in another. For example: the unique code of "1900"
would be the entire chapter of a book in the bible, representing all 25
verses in that chapter, all of which are each a separate record in another
field, and then display them in the RTF2 Control as a group.

This works in access subforms like I want it to for example:
Private Sub form2_Enter()
Me![form2].LinkChildFields = "unique chapter codes"
Me![form2].LinkMasterFields = "unique chapter codes"
End Sub

Thank you
 
S

Stephen Lebans

That's an interesting method John.

As for the TreeNode issue perhaps you could create a simple function in
a standard Code Module(not behind a Form) that returns the currently
selected node.

**Air Code**

Public CurrentNode() as long

' Grab the current Node
' insert your code here for your TreeView.
' I do not use TreeViews so I will just make something up for this
example

'return the value
CurrentNode = Forms!YourFormName.TreeViewControlName.CurrentNode

Then modify your SQL to something like:
strSQL = "SELECT * FROM [tblBible Text] WHERE [unique chapter
codes] = CurrentNode()"


You could also use the EVAL function witht he COntrol directly in the
SQL statement but that's more involved to explain.

If your finished MDB is for public consumption I would liketo place it
on the RTF2 Web page as a sample MDB.
--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.


John Thomas said:
Thanks, I used the third option, that code is below, it seems to work ok,
the thing I need to do now is pass my treeview node selection to it. In the
code below I put in the WHERE number of 1800, any suggestions on passing the
node selection in its place. Any comments on my code below would be also
welcome.

Private Sub RTFControl1_Enter()
Dim DB As Database, RS As Recordset
Dim strSQL As String
Dim var1 As String
Dim var2 As String
Dim var3 As String
Set DB = CurrentDb

'Setup Query
strSQL = "SELECT * FROM [tblBible Text] WHERE [unique chapter
codes] = 1800"
Set RS = DB.OpenRecordset(strSQL)
'Get Book Name
var3 = RS!BookTitle

Do Until RS.EOF
'Get Chapter#, Verse# and Text and assemble string, add some rtf formatting
var1 = RS!Chapter
var2 = RS!Verse
var2 = " \par \par" & "{\cf1\super" & " " & var1 & ":" & var2 & " "
& "}"
'Build string
var3 = var3 & var2 & RS!KJV

RS.MoveNext
Loop

'Add rtf format to raw text
var3 = "{\rtf\ansi\ansicpg1252\deff0{\fonttbl{\f0\fnil\fcharset0 MS Sans
Serif;}}{\colortbl ;\red112\green112\blue255;}\viewkind4\uc1\pard" & var3 &
"}"
'Send to RTF2 Control
Me.RTFControl1.RTFText = var3
Set DB = Nothing
RS.Close
End Sub

Thanks again
"Stephen Lebans"
wrote in message news:[email protected]...
The Access ActiveX Host container only supports simple data binding, in
other words you can only bind the control to a single field.
YOu have a few options:
1) Set the RecordSource for the Form containing the control to a Query
containing the desired data.
2) Use a temp table with a single field bound to the control. Write all
of the relevant data to this field.
3) Use the control unbound instead of bound. Cocatenate all of the data
into a single string and then use this string to update the RTFText
property for the control.
--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.


John Thomas said:
I have data in subforms that I link using the following code as an example,
but RFT2, does support that property. Is there another way for me
to
do
this. It is basiclly groups of records in one field, identified by unique
matching codes in another in another. For example: the unique code
of
"1900"
would be the entire chapter of a book in the bible, representing
all
25
verses in that chapter, all of which are each a separate record in another
field, and then display them in the RTF2 Control as a group.

This works in access subforms like I want it to for example:
Private Sub form2_Enter()
Me![form2].LinkChildFields = "unique chapter codes"
Me![form2].LinkMasterFields = "unique chapter codes"
End Sub

Thank you
 
J

John Thomas

Thanks again, I was code fishing and found out all I had to do was write:
var1 = Me.[unquie chapter codes]

and it gave me the code, except I am running 1 click behind on the sycn,
where when I click on the node, I got to the last one I clicked on. But I
saw it do this before, and then not, so I got a bug somewhere. If I click on
the RTF2 control though it updates just right

Yes it will be public, but I will have to break it down to smaller
databases, 500 mb right now. due to many bible versions and commentaries.
You can strip it down real small for a sample though.

Stephen Lebans said:
That's an interesting method John.

As for the TreeNode issue perhaps you could create a simple function in
a standard Code Module(not behind a Form) that returns the currently
selected node.

**Air Code**

Public CurrentNode() as long

' Grab the current Node
' insert your code here for your TreeView.
' I do not use TreeViews so I will just make something up for this
example

'return the value
CurrentNode = Forms!YourFormName.TreeViewControlName.CurrentNode

Then modify your SQL to something like:
strSQL = "SELECT * FROM [tblBible Text] WHERE [unique chapter
codes] = CurrentNode()"


You could also use the EVAL function witht he COntrol directly in the
SQL statement but that's more involved to explain.

If your finished MDB is for public consumption I would liketo place it
on the RTF2 Web page as a sample MDB.
--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.


John Thomas said:
Thanks, I used the third option, that code is below, it seems to work ok,
the thing I need to do now is pass my treeview node selection to it. In the
code below I put in the WHERE number of 1800, any suggestions on passing the
node selection in its place. Any comments on my code below would be also
welcome.

Private Sub RTFControl1_Enter()
Dim DB As Database, RS As Recordset
Dim strSQL As String
Dim var1 As String
Dim var2 As String
Dim var3 As String
Set DB = CurrentDb

'Setup Query
strSQL = "SELECT * FROM [tblBible Text] WHERE [unique chapter
codes] = 1800"
Set RS = DB.OpenRecordset(strSQL)
'Get Book Name
var3 = RS!BookTitle

Do Until RS.EOF
'Get Chapter#, Verse# and Text and assemble string, add some rtf formatting
var1 = RS!Chapter
var2 = RS!Verse
var2 = " \par \par" & "{\cf1\super" & " " & var1 & ":" & var2 & " "
& "}"
'Build string
var3 = var3 & var2 & RS!KJV

RS.MoveNext
Loop

'Add rtf format to raw text
var3 = "{\rtf\ansi\ansicpg1252\deff0{\fonttbl{\f0\fnil\fcharset0 MS Sans
Serif;}}{\colortbl ;\red112\green112\blue255;}\viewkind4\uc1\pard" & var3 &
"}"
'Send to RTF2 Control
Me.RTFControl1.RTFText = var3
Set DB = Nothing
RS.Close
End Sub

Thanks again
"Stephen Lebans"
wrote in message news:[email protected]...
The Access ActiveX Host container only supports simple data binding, in
other words you can only bind the control to a single field.
YOu have a few options:
1) Set the RecordSource for the Form containing the control to a Query
containing the desired data.
2) Use a temp table with a single field bound to the control. Write all
of the relevant data to this field.
3) Use the control unbound instead of bound. Cocatenate all of the data
into a single string and then use this string to update the RTFText
property for the control.
--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.


I have data in subforms that I link using the following code as an
example,
but RFT2, does support that property. Is there another way for me to
do
this. It is basiclly groups of records in one field, identified by
unique
matching codes in another in another. For example: the unique code of
"1900"
would be the entire chapter of a book in the bible, representing all
25
verses in that chapter, all of which are each a separate record in
another
field, and then display them in the RTF2 Control as a group.

This works in access subforms like I want it to for example:
Private Sub form2_Enter()
Me![form2].LinkChildFields = "unique chapter codes"
Me![form2].LinkMasterFields = "unique chapter codes"
End Sub

Thank you
 

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