Re: Access sending data to Word VBA Userform



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



--
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

"MPH2000" <MPH2000@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:A5677030-BA71-4542-AA3F-6A40332CDADC@xxxxxxxxxxxxxxxx
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?

"Doug Robbins - Word MVP" wrote:

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




--
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

"MPH2000" <MPH2000@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:28B99348-C04C-487D-8099-ADB6DFC36F7A@xxxxxxxxxxxxxxxx
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





.



Relevant Pages

  • Re: Median calculation
    ... Already answered in another newsgroup to which you posted the same question. ... Dim rs As DAO.Recordset ... 'Open a recordset on the table. ... DMedian = rs ...
    (microsoft.public.access.queries)
  • Re: How To Return Record Number From AddNew
    ... Instead, use SQL DML ... source of a recordset: ... Microsoft MVP -- ASP/ASP.NET ... Please reply to the newsgroup. ...
    (microsoft.public.data.ado)
  • Re: Recordset used in Select/Option pick list
    ... Bob Barrows [MVP] wrote: ... to the list of options generated from your recordset. ... What the getstring is doing is constructing a string from all the ... Please reply to the newsgroup. ...
    (microsoft.public.data.ado)
  • Re: Multiple Recordsets
    ... Alex Dybenko (MVP) ... "Rick" wrote in message ... > Dim rs1 As Recordset ...
    (microsoft.public.access.modulesdaovba)
  • Re: Problem with retrieving values in a combo box from a query
    ... I am trying to retrieve values from a query in a list box. ... Although I get recordset when I query ... Dim oConn ... Please reply to the newsgroup. ...
    (microsoft.public.inetserver.asp.db)