Re: Access sending data to Word VBA Userform
- From: "Doug Robbins - Word MVP" <dkr@xxxxxxxxxxxxxxxxxx>
- Date: Sat, 10 Nov 2007 07:03:39 +1000
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
.
- References:
- Re: Access sending data to Word VBA Userform
- From: Doug Robbins - Word MVP
- Re: Access sending data to Word VBA Userform
- From: MPH2000
- Re: Access sending data to Word VBA Userform
- Prev by Date: Re: Access sending data to Word VBA Userform
- Next by Date: Re: Add Pictures to Protected Document
- Previous by thread: Re: Access sending data to Word VBA Userform
- Next by thread: Re: Add Pictures to Protected Document
- Index(es):
Relevant Pages
|
|