Form command button problems - need to change behavior

H

headly

So I have a form with some command buttons.
The buttons I have a problem with are
A) Filter by Selection;
B) Send to Word or Excel

The problem with A) Filter by Selection, the button doesn't use the
currently selected form field, it applies the last used Filter by Selection.
I added the code

' Screen.ActiveForm.ActiveControl.SetFocus
' Screen.ActiveControl.SetFocus

with no luck.

The problem with B) Send to Word/Excel is that the command sends all
database records and I only want to send the current/active record. The code
currently looks like this:

Dim oApp As Object
Set oApp = CreateObject("Word.Application")
DoCmd.RunCommand acCmdOutputToRTF
DoCmd.RunCommand ac
oApp.Visible = True

I'm guessing I need to somehow assign the current record to some record
object then only send that item, it this do-able;

Code examples highly appreciated. THX!
 
H

headly

Hi AK, That's nice looking code but it doesn't work on my machine. Using your
code, I create a new 'template' (it's a document actually) and click either
the single merge or merge all buttons, word starts but no data is transferred.
 
A

Albert D.Kallal

Hi AK, That's nice looking code but it doesn't work on my machine. Using
your
code, I create a new 'template' (it's a document actually) and click
either
the single merge or merge all buttons, word starts but no data is
transferred.

Are you saying the sample download does not work? (remember, when you create
the template, you have to put at LEAST one merge field in the document, or
word will just show a blank document).

So, give the sample a try. It is possible where the mdb file resides my code
can't create a directory called "word". So, try the above and make sure you
at least put one field in. And, if that don't work..then look in the dir of
the mdb, and MANUALLY create a dir called word.
 
Top