Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / November 2007

Tip: Looking for answers? Try searching our database.

Access sending data to Word VBA Userform

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
MPH2000 - 09 Nov 2007 11:44 GMT
Is it possible to send information from an access form to a Word VBA Userform
using code from within access?

I am able to open the the word document and run word macro to launch the
userform but I am unable to populate the text boxes on the word vba userform.

The code for launching word from access is as follows:
Private Sub WritetoContact_Click()
'This routine will open Microsoft Word, Launch the MC_Document Creator and
'populate the control boxes

On Error GoTo Err_WritetoContact_Click

   Dim objWord As Object
   
   Set objWord = CreateObject("Word.Application")
       
   objWord.Run Macroname:="Controller"
   
   
   

Exit_WritetoContact_Click:
   Exit Sub

Err_WritetoContact_Click:
   MsgBox Err.Description
   Resume Exit_WritetoContact_Click
   
End Sub

Any assistance would be much appreciated
Doug Robbins - Word MVP - 09 Nov 2007 12:12 GMT
See the article "Access a database and insert into a Word document the data
that you find there" at:

http://www.word.mvps.org/FAQs/InterDev/GetDataFromDB.htm

Or, this is how you would populate a listbox (or combobox) with data from an
Access table:

Private Sub UserForm_Initialize()

   Dim db As DAO.Database

   Dim rs As DAO.Recordset

   Dim NoOfRecords As Long

   ' Open the database

   Set db = OpenDatabase("D:\Access\ResidencesXP.mdb")

   ' Retrieve the recordset

   Set rs = db.OpenRecordset("SELECT * FROM Owners")

   ' Determine the number of retrieved records

   With rs

        .MoveLast

        NoOfRecords = .RecordCount

        .MoveFirst

   End With

   ' Set the number of Columns = number of Fields in recordset

   ListBox1.ColumnCount = rs.Fields.Count

   ' Load the ListBox with the retrieved records

   ListBox1.Column = rs.GetRows(NoOfRecords)

   ' Cleanup

   rs.Close

   db.Close

   Set rs = Nothing

   Set db = Nothing

End Sub

Signature

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

> Is it possible to send information from an access form to a Word VBA
> Userform
[quoted text clipped - 27 lines]
>
> Any assistance would be much appreciated
MPH2000 - 09 Nov 2007 12:37 GMT
This appears to be using word to obtain the information from Access is it
possible to use Access vba code  to populate the word userform?

> See the article "Access a database and insert into a Word document the data
> that you find there" at:
[quoted text clipped - 83 lines]
> >
> > Any assistance would be much appreciated
Doug Robbins - Word MVP - 09 Nov 2007 21:03 GMT
To get assistance on that, it would be best to ask in an Access newsgroup,
but you should find some things
of interest of fellow Access MVP, Albert Kallal's website at:

http://www.members.shaw.ca/AlbertKallal/wordmerge/index.html

Signature

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

> This appears to be using word to obtain the information from Access is it
> possible to use Access vba code  to populate the word userform?
[quoted text clipped - 90 lines]
>> >
>> > Any assistance would be much appreciated
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.