Editing an Access97 field value from Word97 
Author Message
 Editing an Access97 field value from Word97

Hello all,

I've got a Word97 macro which is taking a Word list of values and inserting
them in a particular field in an Access97 table. Here's the code:

myParaYear = InputBox("Please enter the year for these numbers.", "Year")
ButtonChosen = MsgBox("Is this a new entry? If this is a new entry, click
Yes. If this is an update to a year, click No.", vbYesNo + vbQuestion, "New
entry or update?")
If ButtonChosen = vbNo Then
    myParaDate = InputBox("Please enter today's date in mmddyyyy format.",
"Enter Date")
    myParaYear = "Para" & myParaYear & "Rev" & myParaDate
Else
    myParaYear = "Para" & myParaYear
End If
Set dbs = OpenDatabase("c:\lists.mdb", False)
myYearText = "alter table paragraphs add column " & myParaYear & " text;"
dbs.Execute myYearText
Set Rst = dbs.OpenRecordset("paragraphs", dbOpenDynaset)
For Each oParagraph In ActiveDocument.Paragraphs
    With Rst
        If oParagraph.Range.Text <> "" Then
            .Edit
            .AddNew
            .Fields(myParaYear) = Left(oParagraph.Range.Text, _
            Len(oParagraph.Range.Text) - 1)
            .Update
            .Bookmark = .LastModified
        End If
    End With
Next oParagraph
Rst.Close
dbs.Close

I'm using the .AddNew command because I (foolishly) am not that familiar
with Access. What I need to do is to deposit the values into the field
starting with the first record, not adding new records as I go. I do have an
AutoNumber Primary key field in the table already, if that helps.

Any suggestions? I hope this is enough information. Please let me know if
it's not.

Thanks in advance...

Bob



Mon, 22 Apr 2002 03:00:00 GMT  
 Editing an Access97 field value from Word97
Bob,
Have a look at the help in Access on Edit (.edit) movefirst, movenext.
I believe these are the methods you are missing.

Jeff Davies

Quote:
> Hello all,

> I've got a Word97 macro which is taking a Word list of values and
inserting
> them in a particular field in an Access97 table. Here's the code:

> myParaYear = InputBox("Please enter the year for these numbers.", "Year")
> ButtonChosen = MsgBox("Is this a new entry? If this is a new entry, click
> Yes. If this is an update to a year, click No.", vbYesNo + vbQuestion,
"New
> entry or update?")
> If ButtonChosen = vbNo Then
>     myParaDate = InputBox("Please enter today's date in mmddyyyy format.",
> "Enter Date")
>     myParaYear = "Para" & myParaYear & "Rev" & myParaDate
> Else
>     myParaYear = "Para" & myParaYear
> End If
> Set dbs = OpenDatabase("c:\lists.mdb", False)
> myYearText = "alter table paragraphs add column " & myParaYear & " text;"
> dbs.Execute myYearText
> Set Rst = dbs.OpenRecordset("paragraphs", dbOpenDynaset)
> For Each oParagraph In ActiveDocument.Paragraphs
>     With Rst
>         If oParagraph.Range.Text <> "" Then
>             .Edit
>             .AddNew
>             .Fields(myParaYear) = Left(oParagraph.Range.Text, _
>             Len(oParagraph.Range.Text) - 1)
>             .Update
>             .Bookmark = .LastModified
>         End If
>     End With
> Next oParagraph
> Rst.Close
> dbs.Close

> I'm using the .AddNew command because I (foolishly) am not that familiar
> with Access. What I need to do is to deposit the values into the field
> starting with the first record, not adding new records as I go. I do have
an
> AutoNumber Primary key field in the table already, if that helps.

> Any suggestions? I hope this is enough information. Please let me know if
> it's not.

> Thanks in advance...

> Bob




Tue, 23 Apr 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. passing values between Word97 and Access97

2. Access97 - Editing table hyperlink field by code

3. Extracting to and cc field values from Outlook98 via Access97

4. Access97-Need command button to reset field values

5. Editing a field value in a ADO Recordset

6. How to edit field values w/o updating table

7. Closing Word97 from Access97

8. Pulling Access97 data into Word97 variables

9. Access97-Word97 Mail Merge

10. Access97/Word97/data exchange HELP!!!

11. Access97/Word97 MailMerge

12. Linking Access97 and Word97

 

 
Powered by phpBB® Forum Software