Bookmark Delete From Access

T

tighe

this one is bit odd:

Originally I had a Form in a Word Document, you select the Check box for a
state on the form. Each state has a bookmark, usually a couple pages worth
of text. when you run the code all bookmarks unchecked state bookmarks were
deleted:

If State() = False Then
Selection.GoTo What:=wdGoToBookmark, Name:="State"
With ActiveDocument.Bookmarks
.DefaultSorting = wdSortByName
.ShowHidden = False
End With
Selection.Delete Unit:=wdCharacter, Count:=1
End If

I tried moving it into the code in Access 2007 to run when it opens, since
it is a merge document. i changed the code in word to access:

If Forms![StateForm]![State] = "State" And Forms![StateForm]![Status] <>
"Working" Then
Selection.GoTo what:=wdGoToBookmark, Name:="State"
With ActiveDocument.Bookmarks
.DefaultSorting = wdSortByName
.ShowHidden = False
End With
Selection.Delete Unit:=wdCharacter, Count:=1
End If

the code runs but it deletes everything no matter what i change the "If"
criteria to. also the form is continuous.

thanks for the help in advance.
 
T

tighe

Alex,

thanks for looking into this and with previous help i have recieved from you
in the past.

Unfortunatley that part of the code is the problem. it seems when i run the
code it either doesn't know what record to reference and deletes or keeps
each states bookmark based on only "Alabama" answer. i tried to move records
between state code but now think i need to do the whole string, move record
and then loop through for the next state bookmark.

Alex Dybenko said:
Hi,
just put a stop at:

If Forms![StateForm]![State] = "State" And Forms![StateForm]![Status] <>
"Working" Then

debug your code and check values and how execution going

--
Best regards,
___________
Alex Dybenko (MVP)
http://accessblog.net
http://www.PointLtd.com

tighe said:
this one is bit odd:

Originally I had a Form in a Word Document, you select the Check box for a
state on the form. Each state has a bookmark, usually a couple pages
worth
of text. when you run the code all bookmarks unchecked state bookmarks
were
deleted:

If State() = False Then
Selection.GoTo What:=wdGoToBookmark, Name:="State"
With ActiveDocument.Bookmarks
.DefaultSorting = wdSortByName
.ShowHidden = False
End With
Selection.Delete Unit:=wdCharacter, Count:=1
End If

I tried moving it into the code in Access 2007 to run when it opens, since
it is a merge document. i changed the code in word to access:

If Forms![StateForm]![State] = "State" And Forms![StateForm]![Status] <>
"Working" Then
Selection.GoTo what:=wdGoToBookmark, Name:="State"
With ActiveDocument.Bookmarks
.DefaultSorting = wdSortByName
.ShowHidden = False
End With
Selection.Delete Unit:=wdCharacter, Count:=1
End If

the code runs but it deletes everything no matter what i change the "If"
criteria to. also the form is continuous.

thanks for the help in advance.
 

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