PC Review


Reply
Thread Tools Rate Thread

ACCESS + WORD VBA

 
 
iris
Guest
Posts: n/a
 
      26th Jan 2009
Hello everybody.

I have a table in access with 12 columns.

I have created a form in WORD with 1 combobox and 12 textboxes.

I need to populate the textboxes with values when I choose a value in the
combobox...

can anyone tell me how to do that?

 
Reply With Quote
 
 
 
 
Alex Dybenko
Guest
Posts: n/a
 
      26th Jan 2009
Hi,
look here:
http://accessblog.net/2006/02/merge-...-and-word.html

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


"iris" <(E-Mail Removed)> wrote in message
news:27E01B67-B611-45E6-8F08-(E-Mail Removed)...
> Hello everybody.
>
> I have a table in access with 12 columns.
>
> I have created a form in WORD with 1 combobox and 12 textboxes.
>
> I need to populate the textboxes with values when I choose a value in the
> combobox...
>
> can anyone tell me how to do that?
>

 
Reply With Quote
 
ryguy7272
Guest
Posts: n/a
 
      26th Jan 2009
I'm trying to imagine your design; nothing I can think of makes sense. Have
you taken a look at Mail Merge. That may work for you. As an alternative,
you can set up a Form, choose the appropriate record(s) and then run some VBA
code to push all the data from Access to Word. Take a look at this, and
change the variable names to match your own:

Option Compare Database


Sub PatientForm()

Dim appWord As Word.Application
Dim doc As Word.Document
Dim objWord As Object

On Error Resume Next
err.Clear

Set appWord = GetObject(, "Word.Application")
Set objWord = CreateObject("Word.Application")

If err.Number <> 0 Then

objWord.Documents.Open CurrentProject.Path & "\test.doc"
objWord.Visible = True

End If
'Set doc = appWord.Documents.Open("C:\PatientForm.doc", , True)
Set doc = appWord.Documents.Open(CurrentProject.Path & "\PatientForm.doc", ,
True)
With doc

..FormFields("LastName").Result = Forms!SearchForm!frmsubClients.Form.LastName
..FormFields("FirstName").Result =
Forms!SearchForm!frmsubClients.Form.FirstName
..FormFields("ConsultDate").Result =
Forms!SearchForm!frmsubClients.Form.ConsultDate

..Visible = True
..Activate
End With
Set doc = Nothing
Set appWord = Nothing
Exit Sub
errHandler:
MsgBox err.Number & ": " & err.Description

End Sub


Regards,
Ryan---


--
RyGuy


"iris" wrote:

> Hello everybody.
>
> I have a table in access with 12 columns.
>
> I have created a form in WORD with 1 combobox and 12 textboxes.
>
> I need to populate the textboxes with values when I choose a value in the
> combobox...
>
> can anyone tell me how to do that?
>

 
Reply With Quote
 
iris
Guest
Posts: n/a
 
      26th Jan 2009
Hi Ryan,

thank you for your quick reply.

I open the form from WORD and not from Access... the data base is in access...

The enduser is supposed to use this data in his document.

I need the code in word vba that pulls the data from access to textboxes in
a word form...


"ryguy7272" wrote:

> I'm trying to imagine your design; nothing I can think of makes sense. Have
> you taken a look at Mail Merge. That may work for you. As an alternative,
> you can set up a Form, choose the appropriate record(s) and then run some VBA
> code to push all the data from Access to Word. Take a look at this, and
> change the variable names to match your own:
>
> Option Compare Database
>
>
> Sub PatientForm()
>
> Dim appWord As Word.Application
> Dim doc As Word.Document
> Dim objWord As Object
>
> On Error Resume Next
> err.Clear
>
> Set appWord = GetObject(, "Word.Application")
> Set objWord = CreateObject("Word.Application")
>
> If err.Number <> 0 Then
>
> objWord.Documents.Open CurrentProject.Path & "\test.doc"
> objWord.Visible = True
>
> End If
> 'Set doc = appWord.Documents.Open("C:\PatientForm.doc", , True)
> Set doc = appWord.Documents.Open(CurrentProject.Path & "\PatientForm.doc", ,
> True)
> With doc
>
> .FormFields("LastName").Result = Forms!SearchForm!frmsubClients.Form.LastName
> .FormFields("FirstName").Result =
> Forms!SearchForm!frmsubClients.Form.FirstName
> .FormFields("ConsultDate").Result =
> Forms!SearchForm!frmsubClients.Form.ConsultDate
>
> .Visible = True
> .Activate
> End With
> Set doc = Nothing
> Set appWord = Nothing
> Exit Sub
> errHandler:
> MsgBox err.Number & ": " & err.Description
>
> End Sub
>
>
> Regards,
> Ryan---
>
>
> --
> RyGuy
>
>
> "iris" wrote:
>
> > Hello everybody.
> >
> > I have a table in access with 12 columns.
> >
> > I have created a form in WORD with 1 combobox and 12 textboxes.
> >
> > I need to populate the textboxes with values when I choose a value in the
> > combobox...
> >
> > can anyone tell me how to do that?
> >

 
Reply With Quote
 
ryguy7272
Guest
Posts: n/a
 
      26th Jan 2009
In that case, you could still use Mail Merge:
http://word.mvps.org/FAQs/MailMerge/...AMailMerge.htm

I see that you have already posted in the Word Programming area. Hopefully
someone over there will be able to help you out. This is really a Word
issue; you control Access from Word…Access is kind of just sitting there,
dormant.

Good luck!!


Ryan---

--
RyGuy


"iris" wrote:

> Hi Ryan,
>
> thank you for your quick reply.
>
> I open the form from WORD and not from Access... the data base is in access...
>
> The enduser is supposed to use this data in his document.
>
> I need the code in word vba that pulls the data from access to textboxes in
> a word form...
>
>
> "ryguy7272" wrote:
>
> > I'm trying to imagine your design; nothing I can think of makes sense. Have
> > you taken a look at Mail Merge. That may work for you. As an alternative,
> > you can set up a Form, choose the appropriate record(s) and then run some VBA
> > code to push all the data from Access to Word. Take a look at this, and
> > change the variable names to match your own:
> >
> > Option Compare Database
> >
> >
> > Sub PatientForm()
> >
> > Dim appWord As Word.Application
> > Dim doc As Word.Document
> > Dim objWord As Object
> >
> > On Error Resume Next
> > err.Clear
> >
> > Set appWord = GetObject(, "Word.Application")
> > Set objWord = CreateObject("Word.Application")
> >
> > If err.Number <> 0 Then
> >
> > objWord.Documents.Open CurrentProject.Path & "\test.doc"
> > objWord.Visible = True
> >
> > End If
> > 'Set doc = appWord.Documents.Open("C:\PatientForm.doc", , True)
> > Set doc = appWord.Documents.Open(CurrentProject.Path & "\PatientForm.doc", ,
> > True)
> > With doc
> >
> > .FormFields("LastName").Result = Forms!SearchForm!frmsubClients.Form.LastName
> > .FormFields("FirstName").Result =
> > Forms!SearchForm!frmsubClients.Form.FirstName
> > .FormFields("ConsultDate").Result =
> > Forms!SearchForm!frmsubClients.Form.ConsultDate
> >
> > .Visible = True
> > .Activate
> > End With
> > Set doc = Nothing
> > Set appWord = Nothing
> > Exit Sub
> > errHandler:
> > MsgBox err.Number & ": " & err.Description
> >
> > End Sub
> >
> >
> > Regards,
> > Ryan---
> >
> >
> > --
> > RyGuy
> >
> >
> > "iris" wrote:
> >
> > > Hello everybody.
> > >
> > > I have a table in access with 12 columns.
> > >
> > > I have created a form in WORD with 1 combobox and 12 textboxes.
> > >
> > > I need to populate the textboxes with values when I choose a value in the
> > > combobox...
> > >
> > > can anyone tell me how to do that?
> > >

 
Reply With Quote
 
iris
Guest
Posts: n/a
 
      26th Jan 2009
thenk you rian... I hope someone can!

"ryguy7272" wrote:

> In that case, you could still use Mail Merge:
> http://word.mvps.org/FAQs/MailMerge/...AMailMerge.htm
>
> I see that you have already posted in the Word Programming area. Hopefully
> someone over there will be able to help you out. This is really a Word
> issue; you control Access from Word…Access is kind of just sitting there,
> dormant.
>
> Good luck!!
>
>
> Ryan---
>
> --
> RyGuy
>
>
> "iris" wrote:
>
> > Hi Ryan,
> >
> > thank you for your quick reply.
> >
> > I open the form from WORD and not from Access... the data base is in access...
> >
> > The enduser is supposed to use this data in his document.
> >
> > I need the code in word vba that pulls the data from access to textboxes in
> > a word form...
> >
> >
> > "ryguy7272" wrote:
> >
> > > I'm trying to imagine your design; nothing I can think of makes sense. Have
> > > you taken a look at Mail Merge. That may work for you. As an alternative,
> > > you can set up a Form, choose the appropriate record(s) and then run some VBA
> > > code to push all the data from Access to Word. Take a look at this, and
> > > change the variable names to match your own:
> > >
> > > Option Compare Database
> > >
> > >
> > > Sub PatientForm()
> > >
> > > Dim appWord As Word.Application
> > > Dim doc As Word.Document
> > > Dim objWord As Object
> > >
> > > On Error Resume Next
> > > err.Clear
> > >
> > > Set appWord = GetObject(, "Word.Application")
> > > Set objWord = CreateObject("Word.Application")
> > >
> > > If err.Number <> 0 Then
> > >
> > > objWord.Documents.Open CurrentProject.Path & "\test.doc"
> > > objWord.Visible = True
> > >
> > > End If
> > > 'Set doc = appWord.Documents.Open("C:\PatientForm.doc", , True)
> > > Set doc = appWord.Documents.Open(CurrentProject.Path & "\PatientForm.doc", ,
> > > True)
> > > With doc
> > >
> > > .FormFields("LastName").Result = Forms!SearchForm!frmsubClients.Form.LastName
> > > .FormFields("FirstName").Result =
> > > Forms!SearchForm!frmsubClients.Form.FirstName
> > > .FormFields("ConsultDate").Result =
> > > Forms!SearchForm!frmsubClients.Form.ConsultDate
> > >
> > > .Visible = True
> > > .Activate
> > > End With
> > > Set doc = Nothing
> > > Set appWord = Nothing
> > > Exit Sub
> > > errHandler:
> > > MsgBox err.Number & ": " & err.Description
> > >
> > > End Sub
> > >
> > >
> > > Regards,
> > > Ryan---
> > >
> > >
> > > --
> > > RyGuy
> > >
> > >
> > > "iris" wrote:
> > >
> > > > Hello everybody.
> > > >
> > > > I have a table in access with 12 columns.
> > > >
> > > > I have created a form in WORD with 1 combobox and 12 textboxes.
> > > >
> > > > I need to populate the textboxes with values when I choose a value in the
> > > > combobox...
> > > >
> > > > can anyone tell me how to do that?
> > > >

 
Reply With Quote
 
ryguy7272
Guest
Posts: n/a
 
      29th Jan 2009
Did you get your model working?
Ryan--

--
RyGuy


"iris" wrote:

> thenk you rian... I hope someone can!
>
> "ryguy7272" wrote:
>
> > In that case, you could still use Mail Merge:
> > http://word.mvps.org/FAQs/MailMerge/...AMailMerge.htm
> >
> > I see that you have already posted in the Word Programming area. Hopefully
> > someone over there will be able to help you out. This is really a Word
> > issue; you control Access from Word…Access is kind of just sitting there,
> > dormant.
> >
> > Good luck!!
> >
> >
> > Ryan---
> >
> > --
> > RyGuy
> >
> >
> > "iris" wrote:
> >
> > > Hi Ryan,
> > >
> > > thank you for your quick reply.
> > >
> > > I open the form from WORD and not from Access... the data base is in access...
> > >
> > > The enduser is supposed to use this data in his document.
> > >
> > > I need the code in word vba that pulls the data from access to textboxes in
> > > a word form...
> > >
> > >
> > > "ryguy7272" wrote:
> > >
> > > > I'm trying to imagine your design; nothing I can think of makes sense. Have
> > > > you taken a look at Mail Merge. That may work for you. As an alternative,
> > > > you can set up a Form, choose the appropriate record(s) and then run some VBA
> > > > code to push all the data from Access to Word. Take a look at this, and
> > > > change the variable names to match your own:
> > > >
> > > > Option Compare Database
> > > >
> > > >
> > > > Sub PatientForm()
> > > >
> > > > Dim appWord As Word.Application
> > > > Dim doc As Word.Document
> > > > Dim objWord As Object
> > > >
> > > > On Error Resume Next
> > > > err.Clear
> > > >
> > > > Set appWord = GetObject(, "Word.Application")
> > > > Set objWord = CreateObject("Word.Application")
> > > >
> > > > If err.Number <> 0 Then
> > > >
> > > > objWord.Documents.Open CurrentProject.Path & "\test.doc"
> > > > objWord.Visible = True
> > > >
> > > > End If
> > > > 'Set doc = appWord.Documents.Open("C:\PatientForm.doc", , True)
> > > > Set doc = appWord.Documents.Open(CurrentProject.Path & "\PatientForm.doc", ,
> > > > True)
> > > > With doc
> > > >
> > > > .FormFields("LastName").Result = Forms!SearchForm!frmsubClients.Form.LastName
> > > > .FormFields("FirstName").Result =
> > > > Forms!SearchForm!frmsubClients.Form.FirstName
> > > > .FormFields("ConsultDate").Result =
> > > > Forms!SearchForm!frmsubClients.Form.ConsultDate
> > > >
> > > > .Visible = True
> > > > .Activate
> > > > End With
> > > > Set doc = Nothing
> > > > Set appWord = Nothing
> > > > Exit Sub
> > > > errHandler:
> > > > MsgBox err.Number & ": " & err.Description
> > > >
> > > > End Sub
> > > >
> > > >
> > > > Regards,
> > > > Ryan---
> > > >
> > > >
> > > > --
> > > > RyGuy
> > > >
> > > >
> > > > "iris" wrote:
> > > >
> > > > > Hello everybody.
> > > > >
> > > > > I have a table in access with 12 columns.
> > > > >
> > > > > I have created a form in WORD with 1 combobox and 12 textboxes.
> > > > >
> > > > > I need to populate the textboxes with values when I choose a value in the
> > > > > combobox...
> > > > >
> > > > > can anyone tell me how to do that?
> > > > >

 
Reply With Quote
 
iris
Guest
Posts: n/a
 
      29th Jan 2009
Hi Ryan

Thank you for caring.

After Gregs answer I tried a different approach and now everything is
working like a swiss watch!

Thank You again!

Have a nice day!


"ryguy7272" wrote:

> Did you get your model working?
> Ryan--
>
> --
> RyGuy
>
>
> "iris" wrote:
>
> > thenk you rian... I hope someone can!
> >
> > "ryguy7272" wrote:
> >
> > > In that case, you could still use Mail Merge:
> > > http://word.mvps.org/FAQs/MailMerge/...AMailMerge.htm
> > >
> > > I see that you have already posted in the Word Programming area. Hopefully
> > > someone over there will be able to help you out. This is really a Word
> > > issue; you control Access from Word…Access is kind of just sitting there,
> > > dormant.
> > >
> > > Good luck!!
> > >
> > >
> > > Ryan---
> > >
> > > --
> > > RyGuy
> > >
> > >
> > > "iris" wrote:
> > >
> > > > Hi Ryan,
> > > >
> > > > thank you for your quick reply.
> > > >
> > > > I open the form from WORD and not from Access... the data base is in access...
> > > >
> > > > The enduser is supposed to use this data in his document.
> > > >
> > > > I need the code in word vba that pulls the data from access to textboxes in
> > > > a word form...
> > > >
> > > >
> > > > "ryguy7272" wrote:
> > > >
> > > > > I'm trying to imagine your design; nothing I can think of makes sense. Have
> > > > > you taken a look at Mail Merge. That may work for you. As an alternative,
> > > > > you can set up a Form, choose the appropriate record(s) and then run some VBA
> > > > > code to push all the data from Access to Word. Take a look at this, and
> > > > > change the variable names to match your own:
> > > > >
> > > > > Option Compare Database
> > > > >
> > > > >
> > > > > Sub PatientForm()
> > > > >
> > > > > Dim appWord As Word.Application
> > > > > Dim doc As Word.Document
> > > > > Dim objWord As Object
> > > > >
> > > > > On Error Resume Next
> > > > > err.Clear
> > > > >
> > > > > Set appWord = GetObject(, "Word.Application")
> > > > > Set objWord = CreateObject("Word.Application")
> > > > >
> > > > > If err.Number <> 0 Then
> > > > >
> > > > > objWord.Documents.Open CurrentProject.Path & "\test.doc"
> > > > > objWord.Visible = True
> > > > >
> > > > > End If
> > > > > 'Set doc = appWord.Documents.Open("C:\PatientForm.doc", , True)
> > > > > Set doc = appWord.Documents.Open(CurrentProject.Path & "\PatientForm.doc", ,
> > > > > True)
> > > > > With doc
> > > > >
> > > > > .FormFields("LastName").Result = Forms!SearchForm!frmsubClients.Form.LastName
> > > > > .FormFields("FirstName").Result =
> > > > > Forms!SearchForm!frmsubClients.Form.FirstName
> > > > > .FormFields("ConsultDate").Result =
> > > > > Forms!SearchForm!frmsubClients.Form.ConsultDate
> > > > >
> > > > > .Visible = True
> > > > > .Activate
> > > > > End With
> > > > > Set doc = Nothing
> > > > > Set appWord = Nothing
> > > > > Exit Sub
> > > > > errHandler:
> > > > > MsgBox err.Number & ": " & err.Description
> > > > >
> > > > > End Sub
> > > > >
> > > > >
> > > > > Regards,
> > > > > Ryan---
> > > > >
> > > > >
> > > > > --
> > > > > RyGuy
> > > > >
> > > > >
> > > > > "iris" wrote:
> > > > >
> > > > > > Hello everybody.
> > > > > >
> > > > > > I have a table in access with 12 columns.
> > > > > >
> > > > > > I have created a form in WORD with 1 combobox and 12 textboxes.
> > > > > >
> > > > > > I need to populate the textboxes with values when I choose a value in the
> > > > > > combobox...
> > > > > >
> > > > > > can anyone tell me how to do that?
> > > > > >

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
run mail merge to word from ms access using and save every record as separate word document Rasta Microsoft Access 0 12th Dec 2007 11:22 PM
Mail merge: Word/Access ok but Access/Word is problem =?Utf-8?B?S2V2cnls?= Microsoft Access 4 11th Jul 2006 02:38 AM
How do I output Access Report via Word Macro to Word/Excel instead of Printer? chris@hemingwayc.freeserve.co.uk Microsoft Access Getting Started 13 22nd May 2006 10:06 PM
Word Document pieces in Access Reports print Larger than they are in word Howard Ducat Microsoft Access Reports 5 25th Mar 2004 01:27 AM
How to Access Word active object on other application and Get the word's Document FilePath? Lex Yacc Microsoft C# .NET 0 20th Aug 2003 04:05 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:47 PM.