Word Macro Problem

A

amod.kumar29

Is Any one can tell me about this.

I have to fetch data from MS-Access into word document by pressing a
different keystrokes.

Let here is example wht i have to do...
In open word document When I press keystroke <Alt>+M...it would
retrieve data whose names starts with 'M' from ms-access table ;
similarly if i press <Alt>+L...it would retrieve data whose names
starts with 'L' from ms-access table .
And how to display these data in word document. I am using macros but
when i create one macro with keystroke other keystroke doesn't work.

Can anybody solve this problem & guide me how i can get out from this
problem.


Thanx.......
 
J

Jezebel

1. Create a function that retrieves data from your database. The function
should take an argument -- the letter for which you want to retrieve data,
eg --

Private Sub GetNames(FirstLetter as string)

... retrieve and insert ...
... SELECT [Name] FROM MyTable WHERE ([Name] like '" &
Left$(FirstLetter,1) & "*'";)

...
End Sub


2. Create a method for calling this macro, specifying the argument. You
could use 26 separate macros, eg --

Sub GetNames_L()
GetNames("L")
End Sub

etc

.... but you might want to play around with this. There are many other
options for user input; eg a userform and an input box.
 
V

VBANovice

thanx Jezebel

How can I bound label control with data from ms-access.




1. Create a function that retrieves data from your database. The function
should take an argument -- the letter for which you want to retrieve data,
eg --

Private Sub GetNames(FirstLetter as string)

... retrieve and insert ...
... SELECT [Name] FROM MyTable WHERE ([Name] like '" &
Left$(FirstLetter,1) & "*'";)

...
End Sub


2. Create a method for calling this macro, specifying the argument. You
could use 26 separate macros, eg --

Sub GetNames_L()
GetNames("L")
End Sub

etc

... but you might want to play around with this. There are many other
options for user input; eg a userform and an input box.





Is Any one can tell me about this.

I have to fetch data from MS-Access into word document by pressing a
different keystrokes.

Let here is example wht i have to do...
In open word document When I press keystroke <Alt>+M...it would
retrieve data whose names starts with 'M' from ms-access table ;
similarly if i press <Alt>+L...it would retrieve data whose names
starts with 'L' from ms-access table .
And how to display these data in word document. I am using macros but
when i create one macro with keystroke other keystroke doesn't work.

Can anybody solve this problem & guide me how i can get out from this
problem.


Thanx.......
 
J

Jezebel

This gets very messy. Do you really want to bind it, or just read the data
and display it?



VBANovice said:
thanx Jezebel

How can I bound label control with data from ms-access.




1. Create a function that retrieves data from your database. The function
should take an argument -- the letter for which you want to retrieve
data,
eg --

Private Sub GetNames(FirstLetter as string)

... retrieve and insert ...
... SELECT [Name] FROM MyTable WHERE ([Name] like '" &
Left$(FirstLetter,1) & "*'";)

...
End Sub


2. Create a method for calling this macro, specifying the argument. You
could use 26 separate macros, eg --

Sub GetNames_L()
GetNames("L")
End Sub

etc

... but you might want to play around with this. There are many other
options for user input; eg a userform and an input box.





Is Any one can tell me about this.

I have to fetch data from MS-Access into word document by pressing a
different keystrokes.

Let here is example wht i have to do...
In open word document When I press keystroke <Alt>+M...it would
retrieve data whose names starts with 'M' from ms-access table ;
similarly if i press <Alt>+L...it would retrieve data whose names
starts with 'L' from ms-access table .
And how to display these data in word document. I am using macros but
when i create one macro with keystroke other keystroke doesn't work.

Can anybody solve this problem & guide me how i can get out from this
problem.


Thanx.......
 
V

VBANovice

Dear Jezebel...

I want to display data from ms-access into ms-word controls using
keystokes. My query is running accurately but i am not able to bind it
to Label control in word document.
Record is displaying properly when I press keystokes into the MsgBox
but not able to display those records in Label Control.

expecting u'll give clear solution from urside....

thanx .....

This gets very messy. Do you really want to bind it, or just read the data
and display it?



VBANovice said:
thanx Jezebel

How can I bound label control with data from ms-access.




1. Create a function that retrieves data from your database. The function
should take an argument -- the letter for which you want to retrieve
data,
eg --

Private Sub GetNames(FirstLetter as string)

... retrieve and insert ...
... SELECT [Name] FROM MyTable WHERE ([Name] like '" &
Left$(FirstLetter,1) & "*'";)

...
End Sub


2. Create a method for calling this macro, specifying the argument. You
could use 26 separate macros, eg --

Sub GetNames_L()
GetNames("L")
End Sub

etc

... but you might want to play around with this. There are many other
options for user input; eg a userform and an input box.





Is Any one can tell me about this.

I have to fetch data from MS-Access into word document by pressing a
different keystrokes.

Let here is example wht i have to do...
In open word document When I press keystroke <Alt>+M...it would
retrieve data whose names starts with 'M' from ms-access table ;
similarly if i press <Alt>+L...it would retrieve data whose names
starts with 'L' from ms-access table .
And how to display these data in word document. I am using macros but
when i create one macro with keystroke other keystroke doesn't work.

Can anybody solve this problem & guide me how i can get out from this
problem.


Thanx.......
 
J

Jezebel

'Binding' has a special meaning in data applications, and I think it's not
what you really mean.




VBANovice said:
Dear Jezebel...

I want to display data from ms-access into ms-word controls using
keystokes. My query is running accurately but i am not able to bind it
to Label control in word document.
Record is displaying properly when I press keystokes into the MsgBox
but not able to display those records in Label Control.

expecting u'll give clear solution from urside....

thanx .....

This gets very messy. Do you really want to bind it, or just read the
data
and display it?



VBANovice said:
thanx Jezebel

How can I bound label control with data from ms-access.





Jezebel wrote:
1. Create a function that retrieves data from your database. The
function
should take an argument -- the letter for which you want to retrieve
data,
eg --

Private Sub GetNames(FirstLetter as string)

... retrieve and insert ...
... SELECT [Name] FROM MyTable WHERE ([Name] like '" &
Left$(FirstLetter,1) & "*'";)

...
End Sub


2. Create a method for calling this macro, specifying the argument.
You
could use 26 separate macros, eg --

Sub GetNames_L()
GetNames("L")
End Sub

etc

... but you might want to play around with this. There are many other
options for user input; eg a userform and an input box.





Is Any one can tell me about this.

I have to fetch data from MS-Access into word document by pressing a
different keystrokes.

Let here is example wht i have to do...
In open word document When I press keystroke <Alt>+M...it would
retrieve data whose names starts with 'M' from ms-access table ;
similarly if i press <Alt>+L...it would retrieve data whose names
starts with 'L' from ms-access table .
And how to display these data in word document. I am using macros
but
when i create one macro with keystroke other keystroke doesn't work.

Can anybody solve this problem & guide me how i can get out from
this
problem.


Thanx.......
 
V

VBANovice

Dear Jazabel,
I will make it easier for you to understand my problem. I am very new
to VBA but I know working of macros & use of it. But when it comes to
retrieve data from Ms-Access on to word document I feel my self very-2
novice. I have an application from where I open Word document on the
basis of self made Template other than Normal.dot. I copy my template
at runtime & replace Normal.dot. Now My document opens according to my
template. Now Use of macros starts from here. I have made Module &
write function to access data from MS-Access. When i press key let say
<Alt> + M the query is attached to it is fired & retrieve some data
from table. when i pass this data in message box it displays proper
record. Thing I have to do is to display that data in word document.
Only solution i want is that to display record from MS-Acess onto word
document at Line first of the document.
I hope you will get clear picture of my problem this time.

Thanx

Amod

'Binding' has a special meaning in data applications, and I think it's not
what you really mean.




VBANovice said:
Dear Jezebel...

I want to display data from ms-access into ms-word controls using
keystokes. My query is running accurately but i am not able to bind it
to Label control in word document.
Record is displaying properly when I press keystokes into the MsgBox
but not able to display those records in Label Control.

expecting u'll give clear solution from urside....

thanx .....

This gets very messy. Do you really want to bind it, or just read the
data
and display it?



thanx Jezebel

How can I bound label control with data from ms-access.





Jezebel wrote:
1. Create a function that retrieves data from your database. The
function
should take an argument -- the letter for which you want to retrieve
data,
eg --

Private Sub GetNames(FirstLetter as string)

... retrieve and insert ...
... SELECT [Name] FROM MyTable WHERE ([Name] like '" &
Left$(FirstLetter,1) & "*'";)

...
End Sub


2. Create a method for calling this macro, specifying the argument.
You
could use 26 separate macros, eg --

Sub GetNames_L()
GetNames("L")
End Sub

etc

... but you might want to play around with this. There are many other
options for user input; eg a userform and an input box.





Is Any one can tell me about this.

I have to fetch data from MS-Access into word document by pressing a
different keystrokes.

Let here is example wht i have to do...
In open word document When I press keystroke <Alt>+M...it would
retrieve data whose names starts with 'M' from ms-access table ;
similarly if i press <Alt>+L...it would retrieve data whose names
starts with 'L' from ms-access table .
And how to display these data in word document. I am using macros
but
when i create one macro with keystroke other keystroke doesn't work.

Can anybody solve this problem & guide me how i can get out from
this
problem.


Thanx.......
 
J

Jezebel

Well, at least it's clarified that what you're doing is nothing to do with
data binding.

I don't understand what you're doing replacing normal.dot. You don't need to
do that to create a document using your own template.

As for the rest, do you not like the suggestions already made?





VBANovice said:
Dear Jazabel,
I will make it easier for you to understand my problem. I am very new
to VBA but I know working of macros & use of it. But when it comes to
retrieve data from Ms-Access on to word document I feel my self very-2
novice. I have an application from where I open Word document on the
basis of self made Template other than Normal.dot. I copy my template
at runtime & replace Normal.dot. Now My document opens according to my
template. Now Use of macros starts from here. I have made Module &
write function to access data from MS-Access. When i press key let say
<Alt> + M the query is attached to it is fired & retrieve some data
from table. when i pass this data in message box it displays proper
record. Thing I have to do is to display that data in word document.
Only solution i want is that to display record from MS-Acess onto word
document at Line first of the document.
I hope you will get clear picture of my problem this time.

Thanx

Amod

'Binding' has a special meaning in data applications, and I think it's
not
what you really mean.




VBANovice said:
Dear Jezebel...

I want to display data from ms-access into ms-word controls using
keystokes. My query is running accurately but i am not able to bind it
to Label control in word document.
Record is displaying properly when I press keystokes into the MsgBox
but not able to display those records in Label Control.

expecting u'll give clear solution from urside....

thanx .....


Jezebel wrote:
This gets very messy. Do you really want to bind it, or just read the
data
and display it?



thanx Jezebel

How can I bound label control with data from ms-access.





Jezebel wrote:
1. Create a function that retrieves data from your database. The
function
should take an argument -- the letter for which you want to
retrieve
data,
eg --

Private Sub GetNames(FirstLetter as string)

... retrieve and insert ...
... SELECT [Name] FROM MyTable WHERE ([Name] like '" &
Left$(FirstLetter,1) & "*'";)

...
End Sub


2. Create a method for calling this macro, specifying the argument.
You
could use 26 separate macros, eg --

Sub GetNames_L()
GetNames("L")
End Sub

etc

... but you might want to play around with this. There are many
other
options for user input; eg a userform and an input box.





Is Any one can tell me about this.

I have to fetch data from MS-Access into word document by
pressing a
different keystrokes.

Let here is example wht i have to do...
In open word document When I press keystroke <Alt>+M...it would
retrieve data whose names starts with 'M' from ms-access table ;
similarly if i press <Alt>+L...it would retrieve data whose names
starts with 'L' from ms-access table .
And how to display these data in word document. I am using macros
but
when i create one macro with keystroke other keystroke doesn't
work.

Can anybody solve this problem & guide me how i can get out from
this
problem.


Thanx.......
 
J

Jonathan West

I would strongly recommend not replacing people's normal.dot template.

Take a look at this article

Distributing macros to other users
http://www.word.mvps.org/FAQs/MacrosVBA/DistributeMacros.htm


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org

VBANovice said:
Dear Jazabel,
I will make it easier for you to understand my problem. I am very new
to VBA but I know working of macros & use of it. But when it comes to
retrieve data from Ms-Access on to word document I feel my self very-2
novice. I have an application from where I open Word document on the
basis of self made Template other than Normal.dot. I copy my template
at runtime & replace Normal.dot. Now My document opens according to my
template. Now Use of macros starts from here. I have made Module &
write function to access data from MS-Access. When i press key let say
<Alt> + M the query is attached to it is fired & retrieve some data
from table. when i pass this data in message box it displays proper
record. Thing I have to do is to display that data in word document.
Only solution i want is that to display record from MS-Acess onto word
document at Line first of the document.
I hope you will get clear picture of my problem this time.

Thanx

Amod

'Binding' has a special meaning in data applications, and I think it's
not
what you really mean.




VBANovice said:
Dear Jezebel...

I want to display data from ms-access into ms-word controls using
keystokes. My query is running accurately but i am not able to bind it
to Label control in word document.
Record is displaying properly when I press keystokes into the MsgBox
but not able to display those records in Label Control.

expecting u'll give clear solution from urside....

thanx .....


Jezebel wrote:
This gets very messy. Do you really want to bind it, or just read the
data
and display it?



thanx Jezebel

How can I bound label control with data from ms-access.





Jezebel wrote:
1. Create a function that retrieves data from your database. The
function
should take an argument -- the letter for which you want to
retrieve
data,
eg --

Private Sub GetNames(FirstLetter as string)

... retrieve and insert ...
... SELECT [Name] FROM MyTable WHERE ([Name] like '" &
Left$(FirstLetter,1) & "*'";)

...
End Sub


2. Create a method for calling this macro, specifying the argument.
You
could use 26 separate macros, eg --

Sub GetNames_L()
GetNames("L")
End Sub

etc

... but you might want to play around with this. There are many
other
options for user input; eg a userform and an input box.





Is Any one can tell me about this.

I have to fetch data from MS-Access into word document by
pressing a
different keystrokes.

Let here is example wht i have to do...
In open word document When I press keystroke <Alt>+M...it would
retrieve data whose names starts with 'M' from ms-access table ;
similarly if i press <Alt>+L...it would retrieve data whose names
starts with 'L' from ms-access table .
And how to display these data in word document. I am using macros
but
when i create one macro with keystroke other keystroke doesn't
work.

Can anybody solve this problem & guide me how i can get out from
this
problem.


Thanx.......
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top