Code to add custom auto number to MS Word bookmark

MS Office Access


  • 1. Delete primary key
    This is a bit unusual but it is part of a table upgrade with a new release of software. One of the tables needs to be changed to delete the existing primary key (the index, not the field itself), add a new field and make the new field the primary key. I can successfully add the new field (BenchmarkNo) but have been unable to change the old PK (ProjectNo) into just an index. I used two approaches. The first was to use the ALTER in SQL. The debug.print of the sql is: ALTER tblBenchmarks DROP PRIMARY KEY, ADD PRIMARY KEY ("BenchmarkNo"); For some reason it keeps failing with a syntax error. The second approach was to set the primary value to false. I set the database to the linked database earlier in the procedure. I can step through the code and it locates the primary key: With tdf .Fields.Append .CreateField("BenchmarkNo", dbAutoIncrField) For Each idx In tdf.Indexes If idx.Primary = True Then idx.Primary = False End If Next End With The error I get is "Cannot set the property once the object is part of a collection." when the code tries to set the primary key to false. After a few hours on this I would appreciate some guidance.
  • 2. Lookup and add
    Hi, I have created a database in which the user will enter information into a form and the record goes into a table. One of the fields on the form is Name. As soon as the user enters a name, I would like for access to go to the table of data that has been previously entered and compare what was entered on the form to what is already in the list. By doing that, if the name entered on the form is not in the table, I want a text box on the form to inform the user that the name has been entered 0 times. And if the name is in the table-let's say twice, I want for the text box to inform the user that the name has been entered 2 times and this will be the 3rd time the name will be put into the table. Is that at all possible? Does anybody know where to start with something like this? All help is greatly appreciated.
  • 3. Fields Properties
    I create a recordset: The recordset comes from view or sp. dim cn as adodb.connection dim rc as adodb.recordset set cn = currentproject.connection set rc = New adodb.recordset rc.Open "Select...", cn Now I would like to get the properties for each field in a recordset (rc) Basically, if the data type is integer, long, text ect. Is it possible via vba to get the properties? thanks jcp
  • 4. Split Form Problems
    I'm migrating one application to acc2007 and in split form, I have the following problems, I don't if is impossible or is my mistake. Qustions: 1. I can't change columnWidth after the split form is opened. 2. If I open a split form in hide mode. DoCmd.OpenForm "G1_Exportdata", , , , , acHidden ... run some code Forms!G1_Exportdata.visible=true shows only datasheet. The form header doesn't show. Is possible open a hide split form and then set to visible (datasheet and formheader)? 3. I would like create a popup split form but the size always is screen size. I can't reduce the size. Is it possible? Any help? Thanks jcp

Code to add custom auto number to MS Word bookmark

Postby A_Classic_Man » Sat, 08 Dec 2007 08:24:18 GMT

I have an Access form that sends data to bookmarks in a Word document.
The command button that sends the data to Word also activates code
that adds a "next number" to the form. The number comes from a single
record table "Make Next Number". That number also appears on the Word
Document. Data can be added to the Word bookmarks and sent back to an
Access table.

On occasion, data is originated on the Word document and sent to the
Access table. How do I get a "next number" from the "Make Next Number"
table to add to the record that was originated on the Word document
and sent to the Access table?

Thanks in advance


Re: Code to add custom auto number to MS Word bookmark

Postby A_Classic_Man » Sat, 08 Dec 2007 08:25:32 GMT

I should add that I am using Access and Word 97

Similar Threads:

1.MS Word Custom Properties and bookmarks

Hi hi,

hope this is the best place to start:

We have a MS Word Template that stores important document information in 
3 places: in Document Properties, Document Custom Properties, and inside 
the document in bookmarks. A VBA macro currently manages this task.

The template and the resultant docs are stored on a local file server, 
but we will soon use a SharePoint Portal Server, or WSS to store and 
manage documents instead.

Ideally we want a single doc library, with 'Views' created based on some 
or all of these individual or groups of info.

Can I 'transfer' these three sets of info along with the document itself 
to the SharePoint doc library, so that we can manage potentially 
hundreds of docs in one 'folder' on SharePoint Portal or WSS? What do I 
need to know in order to get the most info out of the documents and into 

Thanks in advance!

ben correct does not use words added to custom dictionary

I copied my custom dictionary from another machine. 

When I  type, the automatic spell checker flags misspelled words as errors 
(ex flags "tso"). After I  click "spelling and grammar",  word finds the 
custom dictionary and recognizes "tso" as a valid word and changes it to caps 
(as desired).  

How can I set it to use the custom dictionary as I type (automatically 
change tso to TSO) ?

It worked on my old machine why does it work differently now?


3.Custom context menu in Word 2007 executing code in Add-In

4.How to add a custom hidden object into MS Word Document


i am working in VC7. I want to add a custom object (Image+Data) into the MS
Word Document. The Data will be something related to the image i.e name of
the image, format details etc and will be linked to the image shown on the
word document. Further more the data will be hidden. i.e. not visible to the
viewer of the document.

i have added the image into the Word document using the following code.

VARIANT var1; VariantInit(&var1);

VARIANT var2; VariantInit(&var2);

var1.vt = VT_BOOL; var1.boolVal = true; //SaveWithDocument

var2.vt = VT_BOOL; var2.boolVal = false; //LinkToFile

spSelect->InlineShapes->AddPicture("C:\\Documents and
Settings\\ahmadjalil\\My Documents\\My Pictures\\Sample.jpg",&var2,&var1);

VariantClear(&var1); VariantClear(&var2);

where spSelect is smart pointer of type Selection Object.

if some one knows about that. Please help me.

Thanks in advance.

Ahmad Jalil Qarshi

Return to MS Office Access


Who is online

Users browsing this forum: No registered users and 8 guest