Bookmark REF Field

E

Eric

I have a template with several Form Fields. I would like to put in a
FormField that is automatically filled in with data that comes form three
other bookmarks. this FormField is a Report ID. The Report ID would be made
up from three different Bookmarks/Fields that the user fills in, such as
UserInitials, FiscalYear and State. The Review ID would automatically update
to ELB2008CA after the user enters the data for UserInitials, FiscalYear and
State.

Does anyone know how I could do this?

Thanks
 
M

macropod

Hi Eric,

Any particular reason for using a formfield rather than just three REF fields? For example:
{REF UserInitials}{REF FiscalYear)(REFState}
or, if you need to incorporate them into a bookmark:
{SET Report_ID "{REF UserInitials}{REF FiscalYear}{REF State}"}
and to do both that and display the Report ID:
{SET Report_ID "{REF UserInitials}{REF FiscalYear}{REF State}"}{REF Report_ID}
 
E

Eric

Thanks Macropod...... OK where to I paste these to try them? Do I create a
Bookmark and us them in the formula or what. The Review ID must be a
bookmark because it gets extracted to a database.

Thanks for the help
--
Eric the Rookie


macropod said:
Hi Eric,

Any particular reason for using a formfield rather than just three REF fields? For example:
{REF UserInitials}{REF FiscalYear)(REFState}
or, if you need to incorporate them into a bookmark:
{SET Report_ID "{REF UserInitials}{REF FiscalYear}{REF State}"}
and to do both that and display the Report ID:
{SET Report_ID "{REF UserInitials}{REF FiscalYear}{REF State}"}{REF Report_ID}

--
Cheers
macropod
[MVP - Microsoft Word]


Eric said:
I have a template with several Form Fields. I would like to put in a
FormField that is automatically filled in with data that comes form three
other bookmarks. this FormField is a Report ID. The Report ID would be made
up from three different Bookmarks/Fields that the user fills in, such as
UserInitials, FiscalYear and State. The Review ID would automatically update
to ELB2008CA after the user enters the data for UserInitials, FiscalYear and
State.

Does anyone know how I could do this?

Thanks
 
M

macropod

Hi Eric,

Paste them wherever you need/want them. Do note, though, that you have to create all the field braces (ie '{}') in pairs via
Ctrl-F9 - plain text braces won't work.

--
Cheers
macropod
[MVP - Microsoft Word]


Eric said:
Thanks Macropod...... OK where to I paste these to try them? Do I create a
Bookmark and us them in the formula or what. The Review ID must be a
bookmark because it gets extracted to a database.

Thanks for the help
--
Eric the Rookie


macropod said:
Hi Eric,

Any particular reason for using a formfield rather than just three REF fields? For example:
{REF UserInitials}{REF FiscalYear)(REFState}
or, if you need to incorporate them into a bookmark:
{SET Report_ID "{REF UserInitials}{REF FiscalYear}{REF State}"}
and to do both that and display the Report ID:
{SET Report_ID "{REF UserInitials}{REF FiscalYear}{REF State}"}{REF Report_ID}

--
Cheers
macropod
[MVP - Microsoft Word]


Eric said:
I have a template with several Form Fields. I would like to put in a
FormField that is automatically filled in with data that comes form three
other bookmarks. this FormField is a Report ID. The Report ID would be made
up from three different Bookmarks/Fields that the user fills in, such as
UserInitials, FiscalYear and State. The Review ID would automatically update
to ELB2008CA after the user enters the data for UserInitials, FiscalYear and
State.

Does anyone know how I could do this?

Thanks
 
E

Eric

I got it! I got it! Thanks Mac..... That worked great!
--
Eric the Rookie


Eric said:
Thanks Macropod...... OK where to I paste these to try them? Do I create a
Bookmark and us them in the formula or what. The Review ID must be a
bookmark because it gets extracted to a database.

Thanks for the help
--
Eric the Rookie


macropod said:
Hi Eric,

Any particular reason for using a formfield rather than just three REF fields? For example:
{REF UserInitials}{REF FiscalYear)(REFState}
or, if you need to incorporate them into a bookmark:
{SET Report_ID "{REF UserInitials}{REF FiscalYear}{REF State}"}
and to do both that and display the Report ID:
{SET Report_ID "{REF UserInitials}{REF FiscalYear}{REF State}"}{REF Report_ID}

--
Cheers
macropod
[MVP - Microsoft Word]


Eric said:
I have a template with several Form Fields. I would like to put in a
FormField that is automatically filled in with data that comes form three
other bookmarks. this FormField is a Report ID. The Report ID would be made
up from three different Bookmarks/Fields that the user fills in, such as
UserInitials, FiscalYear and State. The Review ID would automatically update
to ELB2008CA after the user enters the data for UserInitials, FiscalYear and
State.

Does anyone know how I could do this?

Thanks
 
E

Eric

Macropod, I am successfully using:

{SET Report_ID "{REF UserInitials}{REF FiscalYear}{REF State}"}{REF Report_ID}

But this bookmark is also being exported out to an access database.
Unfortunately this field is not being exported. Would you know why?
--
Eric the Rookie


Eric said:
I got it! I got it! Thanks Mac..... That worked great!
--
Eric the Rookie


Eric said:
Thanks Macropod...... OK where to I paste these to try them? Do I create a
Bookmark and us them in the formula or what. The Review ID must be a
bookmark because it gets extracted to a database.

Thanks for the help
--
Eric the Rookie


macropod said:
Hi Eric,

Any particular reason for using a formfield rather than just three REF fields? For example:
{REF UserInitials}{REF FiscalYear)(REFState}
or, if you need to incorporate them into a bookmark:
{SET Report_ID "{REF UserInitials}{REF FiscalYear}{REF State}"}
and to do both that and display the Report ID:
{SET Report_ID "{REF UserInitials}{REF FiscalYear}{REF State}"}{REF Report_ID}

--
Cheers
macropod
[MVP - Microsoft Word]


I have a template with several Form Fields. I would like to put in a
FormField that is automatically filled in with data that comes form three
other bookmarks. this FormField is a Report ID. The Report ID would be made
up from three different Bookmarks/Fields that the user fills in, such as
UserInitials, FiscalYear and State. The Review ID would automatically update
to ELB2008CA after the user enters the data for UserInitials, FiscalYear and
State.

Does anyone know how I could do this?

Thanks
 
M

macropod

Hi Eric,

The bookmark will be nothing more than a seies of spaces until at least one of the fields 'FiscalYear', 'UserInitials' and 'State'
have been populated. Also, while you can extract formfield text with ".Result", you need to use ".Range.Text" to get a normal
bookmark's text.

Give the following a try. It outputs a list of all visible bookmarks and their text at the end of the document (naturally, the
document will have to be unprotected for this to work):

Sub ListBkMrks()
Dim oBkMrk As Bookmark
If ActiveDocument.Bookmarks.Count > 0 Then
With Selection
.EndKey Unit:=wdStory
.TypeText Text:=vbCrLf & "Bookmark" & vbTab & "Contents"
For Each oBkMrk In ActiveDocument.Bookmarks
.TypeText Text:=vbCrLf & oBkMrk.Name & vbTab & oBkMrk.Range.Text
Next oBkMrk
End With
End If
End Sub

If the fields are populated, you'll get an output like:
Bookmark Contents
FiscalYear FORMTEXT 2008
Report_ID PE2008ACT
State FORMTEXT AB
UserInitials FORMTEXT ME
As you can see, the bookmarks are listed in alpha order and the formfields include 'FORMTEXT' as part of the bookmark text, but the
Report_ID doesn't.

--
Cheers
macropod
[MVP - Microsoft Word]


Eric said:
Macropod, I am successfully using:

{SET Report_ID "{REF UserInitials}{REF FiscalYear}{REF State}"}{REF Report_ID}

But this bookmark is also being exported out to an access database.
Unfortunately this field is not being exported. Would you know why?
--
Eric the Rookie


Eric said:
I got it! I got it! Thanks Mac..... That worked great!
--
Eric the Rookie


Eric said:
Thanks Macropod...... OK where to I paste these to try them? Do I create a
Bookmark and us them in the formula or what. The Review ID must be a
bookmark because it gets extracted to a database.

Thanks for the help
--
Eric the Rookie


:

Hi Eric,

Any particular reason for using a formfield rather than just three REF fields? For example:
{REF UserInitials}{REF FiscalYear)(REFState}
or, if you need to incorporate them into a bookmark:
{SET Report_ID "{REF UserInitials}{REF FiscalYear}{REF State}"}
and to do both that and display the Report ID:
{SET Report_ID "{REF UserInitials}{REF FiscalYear}{REF State}"}{REF Report_ID}

--
Cheers
macropod
[MVP - Microsoft Word]


I have a template with several Form Fields. I would like to put in a
FormField that is automatically filled in with data that comes form three
other bookmarks. this FormField is a Report ID. The Report ID would be made
up from three different Bookmarks/Fields that the user fills in, such as
UserInitials, FiscalYear and State. The Review ID would automatically update
to ELB2008CA after the user enters the data for UserInitials, FiscalYear and
State.

Does anyone know how I could do this?

Thanks
 
E

Eric

Ok Macropod..... we are getting closer. I understand everything that you
said. But here is what I meant.

All of the form fields UserInitials, FiscalYear etc are being filled out and
as expected the Review_ID is automatically filled in. That part works
wonders. And the {REF Report_ID} shows the Report_ID in that field. But for
some reason when I export all bookmarked fields to the Access DBase......
Report_ID does not exist. Evan though the {SET Report_ID proceeds the other
REF fields. All of the other bookmarked fields are User Form Fields and they
export just fine. But I'm thinking because the Report_ID field is not a User
Form Field, rather a REF Field..... that it will not export..... evan if it
is a bookmark. Here is the bookmarked Report_ID REF Field that I am useing.

{SET Report_ID "{REF State}{REF FiscalYear}{REF UserInitials}{REF Report_ID}

This works great for developing the Report_ID, but will not export as a
Bookmark to Access.

Got another Idea or a fix? Thanks you've been a great help!
--
Eric the Rookie


macropod said:
Hi Eric,

The bookmark will be nothing more than a seies of spaces until at least one of the fields 'FiscalYear', 'UserInitials' and 'State'
have been populated. Also, while you can extract formfield text with ".Result", you need to use ".Range.Text" to get a normal
bookmark's text.

Give the following a try. It outputs a list of all visible bookmarks and their text at the end of the document (naturally, the
document will have to be unprotected for this to work):

Sub ListBkMrks()
Dim oBkMrk As Bookmark
If ActiveDocument.Bookmarks.Count > 0 Then
With Selection
.EndKey Unit:=wdStory
.TypeText Text:=vbCrLf & "Bookmark" & vbTab & "Contents"
For Each oBkMrk In ActiveDocument.Bookmarks
.TypeText Text:=vbCrLf & oBkMrk.Name & vbTab & oBkMrk.Range.Text
Next oBkMrk
End With
End If
End Sub

If the fields are populated, you'll get an output like:
Bookmark Contents
FiscalYear FORMTEXT 2008
Report_ID PE2008ACT
State FORMTEXT AB
UserInitials FORMTEXT ME
As you can see, the bookmarks are listed in alpha order and the formfields include 'FORMTEXT' as part of the bookmark text, but the
Report_ID doesn't.

--
Cheers
macropod
[MVP - Microsoft Word]


Eric said:
Macropod, I am successfully using:

{SET Report_ID "{REF UserInitials}{REF FiscalYear}{REF State}"}{REF Report_ID}

But this bookmark is also being exported out to an access database.
Unfortunately this field is not being exported. Would you know why?
--
Eric the Rookie


Eric said:
I got it! I got it! Thanks Mac..... That worked great!
--
Eric the Rookie


:

Thanks Macropod...... OK where to I paste these to try them? Do I create a
Bookmark and us them in the formula or what. The Review ID must be a
bookmark because it gets extracted to a database.

Thanks for the help
--
Eric the Rookie


:

Hi Eric,

Any particular reason for using a formfield rather than just three REF fields? For example:
{REF UserInitials}{REF FiscalYear)(REFState}
or, if you need to incorporate them into a bookmark:
{SET Report_ID "{REF UserInitials}{REF FiscalYear}{REF State}"}
and to do both that and display the Report ID:
{SET Report_ID "{REF UserInitials}{REF FiscalYear}{REF State}"}{REF Report_ID}

--
Cheers
macropod
[MVP - Microsoft Word]


I have a template with several Form Fields. I would like to put in a
FormField that is automatically filled in with data that comes form three
other bookmarks. this FormField is a Report ID. The Report ID would be made
up from three different Bookmarks/Fields that the user fills in, such as
UserInitials, FiscalYear and State. The Review ID would automatically update
to ELB2008CA after the user enters the data for UserInitials, FiscalYear and
State.

Does anyone know how I could do this?

Thanks
 
D

Doug Robbins - Word MVP

How is the export to Access being done?

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

Eric said:
Ok Macropod..... we are getting closer. I understand everything that you
said. But here is what I meant.

All of the form fields UserInitials, FiscalYear etc are being filled out
and
as expected the Review_ID is automatically filled in. That part works
wonders. And the {REF Report_ID} shows the Report_ID in that field. But
for
some reason when I export all bookmarked fields to the Access DBase......
Report_ID does not exist. Evan though the {SET Report_ID proceeds the
other
REF fields. All of the other bookmarked fields are User Form Fields and
they
export just fine. But I'm thinking because the Report_ID field is not a
User
Form Field, rather a REF Field..... that it will not export..... evan if
it
is a bookmark. Here is the bookmarked Report_ID REF Field that I am
useing.

{SET Report_ID "{REF State}{REF FiscalYear}{REF UserInitials}{REF
Report_ID}

This works great for developing the Report_ID, but will not export as a
Bookmark to Access.

Got another Idea or a fix? Thanks you've been a great help!
--
Eric the Rookie


macropod said:
Hi Eric,

The bookmark will be nothing more than a seies of spaces until at least
one of the fields 'FiscalYear', 'UserInitials' and 'State'
have been populated. Also, while you can extract formfield text with
".Result", you need to use ".Range.Text" to get a normal
bookmark's text.

Give the following a try. It outputs a list of all visible bookmarks and
their text at the end of the document (naturally, the
document will have to be unprotected for this to work):

Sub ListBkMrks()
Dim oBkMrk As Bookmark
If ActiveDocument.Bookmarks.Count > 0 Then
With Selection
.EndKey Unit:=wdStory
.TypeText Text:=vbCrLf & "Bookmark" & vbTab & "Contents"
For Each oBkMrk In ActiveDocument.Bookmarks
.TypeText Text:=vbCrLf & oBkMrk.Name & vbTab & oBkMrk.Range.Text
Next oBkMrk
End With
End If
End Sub

If the fields are populated, you'll get an output like:
Bookmark Contents
FiscalYear FORMTEXT 2008
Report_ID PE2008ACT
State FORMTEXT AB
UserInitials FORMTEXT ME
As you can see, the bookmarks are listed in alpha order and the
formfields include 'FORMTEXT' as part of the bookmark text, but the
Report_ID doesn't.

--
Cheers
macropod
[MVP - Microsoft Word]


Eric said:
Macropod, I am successfully using:

{SET Report_ID "{REF UserInitials}{REF FiscalYear}{REF State}"}{REF
Report_ID}

But this bookmark is also being exported out to an access database.
Unfortunately this field is not being exported. Would you know why?
--
Eric the Rookie


:

I got it! I got it! Thanks Mac..... That worked great!
--
Eric the Rookie


:

Thanks Macropod...... OK where to I paste these to try them? Do I
create a
Bookmark and us them in the formula or what. The Review ID must be
a
bookmark because it gets extracted to a database.

Thanks for the help
--
Eric the Rookie


:

Hi Eric,

Any particular reason for using a formfield rather than just three
REF fields? For example:
{REF UserInitials}{REF FiscalYear)(REFState}
or, if you need to incorporate them into a bookmark:
{SET Report_ID "{REF UserInitials}{REF FiscalYear}{REF State}"}
and to do both that and display the Report ID:
{SET Report_ID "{REF UserInitials}{REF FiscalYear}{REF
State}"}{REF Report_ID}

--
Cheers
macropod
[MVP - Microsoft Word]


I have a template with several Form Fields. I would like to put
in a
FormField that is automatically filled in with data that comes
form three
other bookmarks. this FormField is a Report ID. The Report ID
would be made
up from three different Bookmarks/Fields that the user fills in,
such as
UserInitials, FiscalYear and State. The Review ID would
automatically update
to ELB2008CA after the user enters the data for UserInitials,
FiscalYear and
State.

Does anyone know how I could do this?

Thanks
 
M

macropod

Hi Eric,

In that case, Try this:
.. Create a formfield, with a bookmark named 'Report_ID', set its type to 'calculation' and delete the '=' from the 'expression'.
.. Click OK
.. Select the formfield and press Shift-F9 to expose its coding, which should look like:
{ FORMTEXT { }}
.. Within the field in the formfield, insert three new fields (using Ctrl-F9), so that you get a structure looking like:
{ FORMTEXT { { }{ }{ }}}
.. Fill in/around the field braces so that you end up with coding that looks like:
{ FORMTEXT {QUOTE"{REF UserInitials}{REF FiscalYear}{REF State}"}}
.. Lock & use your form.

Now that the 'Report_ID' is managed via a formfield, I expect it will behave the same way as your other formfields.

FWIW, a simpler way to achieve the same outcome given your present document, would be to rename the bookmark created by the SET
field (eg to 'Rpt_ID) and change the { FORMTEXT { }} code to { FORMTEXT {REF Rpt_ID}}.

--
Cheers
macropod
[MVP - Microsoft Word]


Eric said:
Ok Macropod..... we are getting closer. I understand everything that you
said. But here is what I meant.

All of the form fields UserInitials, FiscalYear etc are being filled out and
as expected the Review_ID is automatically filled in. That part works
wonders. And the {REF Report_ID} shows the Report_ID in that field. But for
some reason when I export all bookmarked fields to the Access DBase......
Report_ID does not exist. Evan though the {SET Report_ID proceeds the other
REF fields. All of the other bookmarked fields are User Form Fields and they
export just fine. But I'm thinking because the Report_ID field is not a User
Form Field, rather a REF Field..... that it will not export..... evan if it
is a bookmark. Here is the bookmarked Report_ID REF Field that I am useing.

{SET Report_ID "{REF State}{REF FiscalYear}{REF UserInitials}{REF Report_ID}

This works great for developing the Report_ID, but will not export as a
Bookmark to Access.

Got another Idea or a fix? Thanks you've been a great help!
--
Eric the Rookie


macropod said:
Hi Eric,

The bookmark will be nothing more than a seies of spaces until at least one of the fields 'FiscalYear', 'UserInitials' and
'State'
have been populated. Also, while you can extract formfield text with ".Result", you need to use ".Range.Text" to get a normal
bookmark's text.

Give the following a try. It outputs a list of all visible bookmarks and their text at the end of the document (naturally, the
document will have to be unprotected for this to work):

Sub ListBkMrks()
Dim oBkMrk As Bookmark
If ActiveDocument.Bookmarks.Count > 0 Then
With Selection
.EndKey Unit:=wdStory
.TypeText Text:=vbCrLf & "Bookmark" & vbTab & "Contents"
For Each oBkMrk In ActiveDocument.Bookmarks
.TypeText Text:=vbCrLf & oBkMrk.Name & vbTab & oBkMrk.Range.Text
Next oBkMrk
End With
End If
End Sub

If the fields are populated, you'll get an output like:
Bookmark Contents
FiscalYear FORMTEXT 2008
Report_ID PE2008ACT
State FORMTEXT AB
UserInitials FORMTEXT ME
As you can see, the bookmarks are listed in alpha order and the formfields include 'FORMTEXT' as part of the bookmark text, but
the
Report_ID doesn't.

--
Cheers
macropod
[MVP - Microsoft Word]


Eric said:
Macropod, I am successfully using:

{SET Report_ID "{REF UserInitials}{REF FiscalYear}{REF State}"}{REF Report_ID}

But this bookmark is also being exported out to an access database.
Unfortunately this field is not being exported. Would you know why?
--
Eric the Rookie


:

I got it! I got it! Thanks Mac..... That worked great!
--
Eric the Rookie


:

Thanks Macropod...... OK where to I paste these to try them? Do I create a
Bookmark and us them in the formula or what. The Review ID must be a
bookmark because it gets extracted to a database.

Thanks for the help
--
Eric the Rookie


:

Hi Eric,

Any particular reason for using a formfield rather than just three REF fields? For example:
{REF UserInitials}{REF FiscalYear)(REFState}
or, if you need to incorporate them into a bookmark:
{SET Report_ID "{REF UserInitials}{REF FiscalYear}{REF State}"}
and to do both that and display the Report ID:
{SET Report_ID "{REF UserInitials}{REF FiscalYear}{REF State}"}{REF Report_ID}

--
Cheers
macropod
[MVP - Microsoft Word]


I have a template with several Form Fields. I would like to put in a
FormField that is automatically filled in with data that comes form three
other bookmarks. this FormField is a Report ID. The Report ID would be made
up from three different Bookmarks/Fields that the user fills in, such as
UserInitials, FiscalYear and State. The Review ID would automatically update
to ELB2008CA after the user enters the data for UserInitials, FiscalYear and
State.

Does anyone know how I could do this?

Thanks
 
E

Eric

Hey Doug! The export is being done using your awesome code shown below:

Sub Export()
'
'
'
Dim vConnection As New ADODB.Connection
Dim vRecordSet As New ADODB.Recordset
Dim SH As Shell32.Shell
Dim Fldr As Shell32.Folder
Dim FldrPath As String
Dim RecordDoc As String
Dim dsource As String
Dim Source As Document
Dim i As Long, j As Long
Dim FileToKill As String

'Get the folder where the forms have been saved.

Set SH = New Shell32.Shell
Set Fldr = SH.BrowseForFolder(0, "Select the Directory (Folder) that
contains your Review Report", &H400)
If Not Fldr Is Nothing Then
FldrPath = Fldr.Items.Item.Path & "\"
End If
Set Fldr = Nothing
RecordDoc = Dir$(FldrPath & "*.doc")

With Dialogs(wdDialogFileOpen)
MsgBox "Locate the Review Tracker Database and select it"
If .Display <> -1 Then
dsource = ""
Else
dsource = WordBasic.FileNameInfo$(.Name, 1)
End If
End With
' Make sure the user selected an Access database
If Right(dsource, 3) <> "mdb" Then
MsgBox "You did not select a valid Access Database file type (.mdb) Review
Tracker. Locate the Review Tracker Database....and select it to proceed."
Exit Sub
Else
dsource = dsource & ";"
End If

vConnection.ConnectionString = "data source=" & dsource & _
"Provider=Microsoft.Jet.OLEDB.4.0;"

vConnection.Open

vRecordSet.Open "Review", vConnection, adOpenKeyset, adLockOptimistic

i = 0
While RecordDoc <> ""
vRecordSet.AddNew
Set Source = Documents.Open(FldrPath & RecordDoc)
With Source
For j = 1 To vRecordSet.Fields.Count
If .Bookmarks.Exists(vRecordSet.Fields(j - 1).Name) Then
If .FormFields(vRecordSet.Fields(j - 1).Name).Result <> ""
Then
vRecordSet(vRecordSet.Fields(j - 1).Name) = _
.FormFields(vRecordSet.Fields(j - 1).Name).Result
End If
End If
Next j
End With
vRecordSet.Update
i = i + 1
FileToKill = Source.FullName
Source.SaveAs FldrPath & "Processed\" & Source.Name
Source.Close wdDoNotSaveChanges
Kill FileToKill
RecordDoc = Dir
Wend

MsgBox i & " Records Added."

vRecordSet.Close
vConnection.Close
Set vRecordSet = Nothing
Set vConnection = Nothing

End Sub
--
Eric the Rookie


Doug Robbins - Word MVP said:
How is the export to Access being done?

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

Eric said:
Ok Macropod..... we are getting closer. I understand everything that you
said. But here is what I meant.

All of the form fields UserInitials, FiscalYear etc are being filled out
and
as expected the Review_ID is automatically filled in. That part works
wonders. And the {REF Report_ID} shows the Report_ID in that field. But
for
some reason when I export all bookmarked fields to the Access DBase......
Report_ID does not exist. Evan though the {SET Report_ID proceeds the
other
REF fields. All of the other bookmarked fields are User Form Fields and
they
export just fine. But I'm thinking because the Report_ID field is not a
User
Form Field, rather a REF Field..... that it will not export..... evan if
it
is a bookmark. Here is the bookmarked Report_ID REF Field that I am
useing.

{SET Report_ID "{REF State}{REF FiscalYear}{REF UserInitials}{REF
Report_ID}

This works great for developing the Report_ID, but will not export as a
Bookmark to Access.

Got another Idea or a fix? Thanks you've been a great help!
--
Eric the Rookie


macropod said:
Hi Eric,

The bookmark will be nothing more than a seies of spaces until at least
one of the fields 'FiscalYear', 'UserInitials' and 'State'
have been populated. Also, while you can extract formfield text with
".Result", you need to use ".Range.Text" to get a normal
bookmark's text.

Give the following a try. It outputs a list of all visible bookmarks and
their text at the end of the document (naturally, the
document will have to be unprotected for this to work):

Sub ListBkMrks()
Dim oBkMrk As Bookmark
If ActiveDocument.Bookmarks.Count > 0 Then
With Selection
.EndKey Unit:=wdStory
.TypeText Text:=vbCrLf & "Bookmark" & vbTab & "Contents"
For Each oBkMrk In ActiveDocument.Bookmarks
.TypeText Text:=vbCrLf & oBkMrk.Name & vbTab & oBkMrk.Range.Text
Next oBkMrk
End With
End If
End Sub

If the fields are populated, you'll get an output like:
Bookmark Contents
FiscalYear FORMTEXT 2008
Report_ID PE2008ACT
State FORMTEXT AB
UserInitials FORMTEXT ME
As you can see, the bookmarks are listed in alpha order and the
formfields include 'FORMTEXT' as part of the bookmark text, but the
Report_ID doesn't.

--
Cheers
macropod
[MVP - Microsoft Word]


Macropod, I am successfully using:

{SET Report_ID "{REF UserInitials}{REF FiscalYear}{REF State}"}{REF
Report_ID}

But this bookmark is also being exported out to an access database.
Unfortunately this field is not being exported. Would you know why?
--
Eric the Rookie


:

I got it! I got it! Thanks Mac..... That worked great!
--
Eric the Rookie


:

Thanks Macropod...... OK where to I paste these to try them? Do I
create a
Bookmark and us them in the formula or what. The Review ID must be
a
bookmark because it gets extracted to a database.

Thanks for the help
--
Eric the Rookie


:

Hi Eric,

Any particular reason for using a formfield rather than just three
REF fields? For example:
{REF UserInitials}{REF FiscalYear)(REFState}
or, if you need to incorporate them into a bookmark:
{SET Report_ID "{REF UserInitials}{REF FiscalYear}{REF State}"}
and to do both that and display the Report ID:
{SET Report_ID "{REF UserInitials}{REF FiscalYear}{REF
State}"}{REF Report_ID}

--
Cheers
macropod
[MVP - Microsoft Word]


I have a template with several Form Fields. I would like to put
in a
FormField that is automatically filled in with data that comes
form three
other bookmarks. this FormField is a Report ID. The Report ID
would be made
up from three different Bookmarks/Fields that the user fills in,
such as
UserInitials, FiscalYear and State. The Review ID would
automatically update
to ELB2008CA after the user enters the data for UserInitials,
FiscalYear and
State.

Does anyone know how I could do this?

Thanks
 
E

Eric

I'll give that a try and let you know.... Thanks
--
Eric the Rookie


macropod said:
Hi Eric,

In that case, Try this:
.. Create a formfield, with a bookmark named 'Report_ID', set its type to 'calculation' and delete the '=' from the 'expression'.
.. Click OK
.. Select the formfield and press Shift-F9 to expose its coding, which should look like:
{ FORMTEXT { }}
.. Within the field in the formfield, insert three new fields (using Ctrl-F9), so that you get a structure looking like:
{ FORMTEXT { { }{ }{ }}}
.. Fill in/around the field braces so that you end up with coding that looks like:
{ FORMTEXT {QUOTE"{REF UserInitials}{REF FiscalYear}{REF State}"}}
.. Lock & use your form.

Now that the 'Report_ID' is managed via a formfield, I expect it will behave the same way as your other formfields.

FWIW, a simpler way to achieve the same outcome given your present document, would be to rename the bookmark created by the SET
field (eg to 'Rpt_ID) and change the { FORMTEXT { }} code to { FORMTEXT {REF Rpt_ID}}.

--
Cheers
macropod
[MVP - Microsoft Word]


Eric said:
Ok Macropod..... we are getting closer. I understand everything that you
said. But here is what I meant.

All of the form fields UserInitials, FiscalYear etc are being filled out and
as expected the Review_ID is automatically filled in. That part works
wonders. And the {REF Report_ID} shows the Report_ID in that field. But for
some reason when I export all bookmarked fields to the Access DBase......
Report_ID does not exist. Evan though the {SET Report_ID proceeds the other
REF fields. All of the other bookmarked fields are User Form Fields and they
export just fine. But I'm thinking because the Report_ID field is not a User
Form Field, rather a REF Field..... that it will not export..... evan if it
is a bookmark. Here is the bookmarked Report_ID REF Field that I am useing.

{SET Report_ID "{REF State}{REF FiscalYear}{REF UserInitials}{REF Report_ID}

This works great for developing the Report_ID, but will not export as a
Bookmark to Access.

Got another Idea or a fix? Thanks you've been a great help!
--
Eric the Rookie


macropod said:
Hi Eric,

The bookmark will be nothing more than a seies of spaces until at least one of the fields 'FiscalYear', 'UserInitials' and
'State'
have been populated. Also, while you can extract formfield text with ".Result", you need to use ".Range.Text" to get a normal
bookmark's text.

Give the following a try. It outputs a list of all visible bookmarks and their text at the end of the document (naturally, the
document will have to be unprotected for this to work):

Sub ListBkMrks()
Dim oBkMrk As Bookmark
If ActiveDocument.Bookmarks.Count > 0 Then
With Selection
.EndKey Unit:=wdStory
.TypeText Text:=vbCrLf & "Bookmark" & vbTab & "Contents"
For Each oBkMrk In ActiveDocument.Bookmarks
.TypeText Text:=vbCrLf & oBkMrk.Name & vbTab & oBkMrk.Range.Text
Next oBkMrk
End With
End If
End Sub

If the fields are populated, you'll get an output like:
Bookmark Contents
FiscalYear FORMTEXT 2008
Report_ID PE2008ACT
State FORMTEXT AB
UserInitials FORMTEXT ME
As you can see, the bookmarks are listed in alpha order and the formfields include 'FORMTEXT' as part of the bookmark text, but
the
Report_ID doesn't.

--
Cheers
macropod
[MVP - Microsoft Word]


Macropod, I am successfully using:

{SET Report_ID "{REF UserInitials}{REF FiscalYear}{REF State}"}{REF Report_ID}

But this bookmark is also being exported out to an access database.
Unfortunately this field is not being exported. Would you know why?
--
Eric the Rookie


:

I got it! I got it! Thanks Mac..... That worked great!
--
Eric the Rookie


:

Thanks Macropod...... OK where to I paste these to try them? Do I create a
Bookmark and us them in the formula or what. The Review ID must be a
bookmark because it gets extracted to a database.

Thanks for the help
--
Eric the Rookie


:

Hi Eric,

Any particular reason for using a formfield rather than just three REF fields? For example:
{REF UserInitials}{REF FiscalYear)(REFState}
or, if you need to incorporate them into a bookmark:
{SET Report_ID "{REF UserInitials}{REF FiscalYear}{REF State}"}
and to do both that and display the Report ID:
{SET Report_ID "{REF UserInitials}{REF FiscalYear}{REF State}"}{REF Report_ID}

--
Cheers
macropod
[MVP - Microsoft Word]


I have a template with several Form Fields. I would like to put in a
FormField that is automatically filled in with data that comes form three
other bookmarks. this FormField is a Report ID. The Report ID would be made
up from three different Bookmarks/Fields that the user fills in, such as
UserInitials, FiscalYear and State. The Review ID would automatically update
to ELB2008CA after the user enters the data for UserInitials, FiscalYear and
State.

Does anyone know how I could do this?

Thanks
 
M

macropod

Hi Eric,

The reason that code isn't picking up the Report_ID, is because it only looks in formfields - but the Report_ID wasn't in one. You
can get around that by explicitly referencing the Report_ID bookmark's text, as demonstrated in my earlier post, or by getting the
Report_ID into a formfield, as demonstrated in my later post.

--
Cheers
macropod
[MVP - Microsoft Word]


Eric said:
Hey Doug! The export is being done using your awesome code shown below:

Sub Export()
'
'
'
Dim vConnection As New ADODB.Connection
Dim vRecordSet As New ADODB.Recordset
Dim SH As Shell32.Shell
Dim Fldr As Shell32.Folder
Dim FldrPath As String
Dim RecordDoc As String
Dim dsource As String
Dim Source As Document
Dim i As Long, j As Long
Dim FileToKill As String

'Get the folder where the forms have been saved.

Set SH = New Shell32.Shell
Set Fldr = SH.BrowseForFolder(0, "Select the Directory (Folder) that
contains your Review Report", &H400)
If Not Fldr Is Nothing Then
FldrPath = Fldr.Items.Item.Path & "\"
End If
Set Fldr = Nothing
RecordDoc = Dir$(FldrPath & "*.doc")

With Dialogs(wdDialogFileOpen)
MsgBox "Locate the Review Tracker Database and select it"
If .Display <> -1 Then
dsource = ""
Else
dsource = WordBasic.FileNameInfo$(.Name, 1)
End If
End With
' Make sure the user selected an Access database
If Right(dsource, 3) <> "mdb" Then
MsgBox "You did not select a valid Access Database file type (.mdb) Review
Tracker. Locate the Review Tracker Database....and select it to proceed."
Exit Sub
Else
dsource = dsource & ";"
End If

vConnection.ConnectionString = "data source=" & dsource & _
"Provider=Microsoft.Jet.OLEDB.4.0;"

vConnection.Open

vRecordSet.Open "Review", vConnection, adOpenKeyset, adLockOptimistic

i = 0
While RecordDoc <> ""
vRecordSet.AddNew
Set Source = Documents.Open(FldrPath & RecordDoc)
With Source
For j = 1 To vRecordSet.Fields.Count
If .Bookmarks.Exists(vRecordSet.Fields(j - 1).Name) Then
If .FormFields(vRecordSet.Fields(j - 1).Name).Result <> ""
Then
vRecordSet(vRecordSet.Fields(j - 1).Name) = _
.FormFields(vRecordSet.Fields(j - 1).Name).Result
End If
End If
Next j
End With
vRecordSet.Update
i = i + 1
FileToKill = Source.FullName
Source.SaveAs FldrPath & "Processed\" & Source.Name
Source.Close wdDoNotSaveChanges
Kill FileToKill
RecordDoc = Dir
Wend

MsgBox i & " Records Added."

vRecordSet.Close
vConnection.Close
Set vRecordSet = Nothing
Set vConnection = Nothing

End Sub
--
Eric the Rookie


Doug Robbins - Word MVP said:
How is the export to Access being done?

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

Eric said:
Ok Macropod..... we are getting closer. I understand everything that you
said. But here is what I meant.

All of the form fields UserInitials, FiscalYear etc are being filled out
and
as expected the Review_ID is automatically filled in. That part works
wonders. And the {REF Report_ID} shows the Report_ID in that field. But
for
some reason when I export all bookmarked fields to the Access DBase......
Report_ID does not exist. Evan though the {SET Report_ID proceeds the
other
REF fields. All of the other bookmarked fields are User Form Fields and
they
export just fine. But I'm thinking because the Report_ID field is not a
User
Form Field, rather a REF Field..... that it will not export..... evan if
it
is a bookmark. Here is the bookmarked Report_ID REF Field that I am
useing.

{SET Report_ID "{REF State}{REF FiscalYear}{REF UserInitials}{REF
Report_ID}

This works great for developing the Report_ID, but will not export as a
Bookmark to Access.

Got another Idea or a fix? Thanks you've been a great help!
--
Eric the Rookie


:

Hi Eric,

The bookmark will be nothing more than a seies of spaces until at least
one of the fields 'FiscalYear', 'UserInitials' and 'State'
have been populated. Also, while you can extract formfield text with
".Result", you need to use ".Range.Text" to get a normal
bookmark's text.

Give the following a try. It outputs a list of all visible bookmarks and
their text at the end of the document (naturally, the
document will have to be unprotected for this to work):

Sub ListBkMrks()
Dim oBkMrk As Bookmark
If ActiveDocument.Bookmarks.Count > 0 Then
With Selection
.EndKey Unit:=wdStory
.TypeText Text:=vbCrLf & "Bookmark" & vbTab & "Contents"
For Each oBkMrk In ActiveDocument.Bookmarks
.TypeText Text:=vbCrLf & oBkMrk.Name & vbTab & oBkMrk.Range.Text
Next oBkMrk
End With
End If
End Sub

If the fields are populated, you'll get an output like:
Bookmark Contents
FiscalYear FORMTEXT 2008
Report_ID PE2008ACT
State FORMTEXT AB
UserInitials FORMTEXT ME
As you can see, the bookmarks are listed in alpha order and the
formfields include 'FORMTEXT' as part of the bookmark text, but the
Report_ID doesn't.

--
Cheers
macropod
[MVP - Microsoft Word]


Macropod, I am successfully using:

{SET Report_ID "{REF UserInitials}{REF FiscalYear}{REF State}"}{REF
Report_ID}

But this bookmark is also being exported out to an access database.
Unfortunately this field is not being exported. Would you know why?
--
Eric the Rookie


:

I got it! I got it! Thanks Mac..... That worked great!
--
Eric the Rookie


:

Thanks Macropod...... OK where to I paste these to try them? Do I
create a
Bookmark and us them in the formula or what. The Review ID must be
a
bookmark because it gets extracted to a database.

Thanks for the help
--
Eric the Rookie


:

Hi Eric,

Any particular reason for using a formfield rather than just three
REF fields? For example:
{REF UserInitials}{REF FiscalYear)(REFState}
or, if you need to incorporate them into a bookmark:
{SET Report_ID "{REF UserInitials}{REF FiscalYear}{REF State}"}
and to do both that and display the Report ID:
{SET Report_ID "{REF UserInitials}{REF FiscalYear}{REF
State}"}{REF Report_ID}

--
Cheers
macropod
[MVP - Microsoft Word]


I have a template with several Form Fields. I would like to put
in a
FormField that is automatically filled in with data that comes
form three
other bookmarks. this FormField is a Report ID. The Report ID
would be made
up from three different Bookmarks/Fields that the user fills in,
such as
UserInitials, FiscalYear and State. The Review ID would
automatically update
to ELB2008CA after the user enters the data for UserInitials,
FiscalYear and
State.

Does anyone know how I could do this?

Thanks
 
E

Eric

MacroPod is on his game. That worked great! Thanks a lot!
--
Eric the Rookie


Eric said:
I'll give that a try and let you know.... Thanks
--
Eric the Rookie


macropod said:
Hi Eric,

In that case, Try this:
.. Create a formfield, with a bookmark named 'Report_ID', set its type to 'calculation' and delete the '=' from the 'expression'.
.. Click OK
.. Select the formfield and press Shift-F9 to expose its coding, which should look like:
{ FORMTEXT { }}
.. Within the field in the formfield, insert three new fields (using Ctrl-F9), so that you get a structure looking like:
{ FORMTEXT { { }{ }{ }}}
.. Fill in/around the field braces so that you end up with coding that looks like:
{ FORMTEXT {QUOTE"{REF UserInitials}{REF FiscalYear}{REF State}"}}
.. Lock & use your form.

Now that the 'Report_ID' is managed via a formfield, I expect it will behave the same way as your other formfields.

FWIW, a simpler way to achieve the same outcome given your present document, would be to rename the bookmark created by the SET
field (eg to 'Rpt_ID) and change the { FORMTEXT { }} code to { FORMTEXT {REF Rpt_ID}}.

--
Cheers
macropod
[MVP - Microsoft Word]


Eric said:
Ok Macropod..... we are getting closer. I understand everything that you
said. But here is what I meant.

All of the form fields UserInitials, FiscalYear etc are being filled out and
as expected the Review_ID is automatically filled in. That part works
wonders. And the {REF Report_ID} shows the Report_ID in that field. But for
some reason when I export all bookmarked fields to the Access DBase......
Report_ID does not exist. Evan though the {SET Report_ID proceeds the other
REF fields. All of the other bookmarked fields are User Form Fields and they
export just fine. But I'm thinking because the Report_ID field is not a User
Form Field, rather a REF Field..... that it will not export..... evan if it
is a bookmark. Here is the bookmarked Report_ID REF Field that I am useing.

{SET Report_ID "{REF State}{REF FiscalYear}{REF UserInitials}{REF Report_ID}

This works great for developing the Report_ID, but will not export as a
Bookmark to Access.

Got another Idea or a fix? Thanks you've been a great help!
--
Eric the Rookie


:

Hi Eric,

The bookmark will be nothing more than a seies of spaces until at least one of the fields 'FiscalYear', 'UserInitials' and
'State'
have been populated. Also, while you can extract formfield text with ".Result", you need to use ".Range.Text" to get a normal
bookmark's text.

Give the following a try. It outputs a list of all visible bookmarks and their text at the end of the document (naturally, the
document will have to be unprotected for this to work):

Sub ListBkMrks()
Dim oBkMrk As Bookmark
If ActiveDocument.Bookmarks.Count > 0 Then
With Selection
.EndKey Unit:=wdStory
.TypeText Text:=vbCrLf & "Bookmark" & vbTab & "Contents"
For Each oBkMrk In ActiveDocument.Bookmarks
.TypeText Text:=vbCrLf & oBkMrk.Name & vbTab & oBkMrk.Range.Text
Next oBkMrk
End With
End If
End Sub

If the fields are populated, you'll get an output like:
Bookmark Contents
FiscalYear FORMTEXT 2008
Report_ID PE2008ACT
State FORMTEXT AB
UserInitials FORMTEXT ME
As you can see, the bookmarks are listed in alpha order and the formfields include 'FORMTEXT' as part of the bookmark text, but
the
Report_ID doesn't.

--
Cheers
macropod
[MVP - Microsoft Word]


Macropod, I am successfully using:

{SET Report_ID "{REF UserInitials}{REF FiscalYear}{REF State}"}{REF Report_ID}

But this bookmark is also being exported out to an access database.
Unfortunately this field is not being exported. Would you know why?
--
Eric the Rookie


:

I got it! I got it! Thanks Mac..... That worked great!
--
Eric the Rookie


:

Thanks Macropod...... OK where to I paste these to try them? Do I create a
Bookmark and us them in the formula or what. The Review ID must be a
bookmark because it gets extracted to a database.

Thanks for the help
--
Eric the Rookie


:

Hi Eric,

Any particular reason for using a formfield rather than just three REF fields? For example:
{REF UserInitials}{REF FiscalYear)(REFState}
or, if you need to incorporate them into a bookmark:
{SET Report_ID "{REF UserInitials}{REF FiscalYear}{REF State}"}
and to do both that and display the Report ID:
{SET Report_ID "{REF UserInitials}{REF FiscalYear}{REF State}"}{REF Report_ID}

--
Cheers
macropod
[MVP - Microsoft Word]


I have a template with several Form Fields. I would like to put in a
FormField that is automatically filled in with data that comes form three
other bookmarks. this FormField is a Report ID. The Report ID would be made
up from three different Bookmarks/Fields that the user fills in, such as
UserInitials, FiscalYear and State. The Review ID would automatically update
to ELB2008CA after the user enters the data for UserInitials, FiscalYear and
State.

Does anyone know how I could do this?

Thanks
 

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