Solved

On the use of "SendKeys"

Posted on 2001-09-18
10
475 Views
Last Modified: 2012-08-14
Hi !
In an app I use SendKeys quite often to automate
som othervise manual operations.
There is however one place where it seems that this method
is difficult, namely in the opening screen of Access
where one has Tables, Queries, Forms etc.
Are these tabs adressable by SendKeys ?
I see no undescores in the folder-names.

Jan
0
Comment
Question by:skyberg
10 Comments
 
LVL 49

Expert Comment

by:Ryan Chong
ID: 6490194
Hi skyberg,

So maybe you need to call that particular Sub as:

Call Command1_Click()
0
 
LVL 4

Expert Comment

by:maatthias
ID: 6490255
They are indeed addressable.  Once an object (table, query etc.) is selected, Shift + Tab highlights the object name.  Then, left or right arrows get you where you need to go.

Take this for what it's worth, but I've never been hot on using SendKeys.  Pretty much anything you need to do is better handled with proper form VBA code and Jet SQL.  But then there ya go.

Best.
0
 
LVL 6

Expert Comment

by:cjswimmer
ID: 6490372
use DoCmd.SelectObject and set the last parameter to True to have the object selected in the database window.  Here are the specifics (from the help file)

DoCmd.SelectObject objecttype[, objectname][, indatabasewindow]

objecttype
One of the following intrinsic constants:
   acForm
   acMacro
   acModule
   acQuery
   acReport
   acTable
Note - The constant acDefault, which appears in the Auto List Members list for this argument, is invalid for this argument. You must choose one of the constants listed above.

objectname
A string expression that's the valid name of an object of the type selected by the objecttype argument. This is a required argument, unless you specify True (?1) for the indatabasewindow argument. If you specify True for the indatabasewindow argument and leave the objectname argument blank, Microsoft Access selects the tab in the Database window that corresponds to the database object you specify in the objecttype argument.

indatabasewindow
Use True to select the object in the Database window. Use False (0) to select an object that's already open. If you leave this argument blank, the default (False) is assumed.

Remarks
If you set the indatabasewindow argument to True and leave the objectname argument blank, you must include the objectname argument's comma. If you leave a trailing argument blank, don't use a comma following the last argument you specify.


hope this helps - cjswimmer
0
 
LVL 54

Expert Comment

by:nico5038
ID: 6490462
Hi skiberg,

Just a warning: to try to minimize on Sendkey's as it's directed to the active window. When the window-focus is shifted to another application, your keystrokes are "lost"!

The "cjswimmer" approach is superior as it will work in all cases !

Nic;o)
0
 

Author Comment

by:skyberg
ID: 6490590
Using "DoCmd.SelectObject" sounds tempting in the case
where one knows the name of the objects.
In the case of tables, one can "Mark all" by "SendKeys".

In my case I am about to convert a number of (min 20) data-
bases.

By running in a loop, all the bases could easily be
converted in the case of tables.
The other objects seem not to be that easy.
As far I can see, one has to go into the interior of
the bases in order to get hold of the differentb objects.
I had hoped to avoid just that.

I will return with an asessment.

Jan
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 6

Accepted Solution

by:
cjswimmer earned 50 total points
ID: 6490639
I'm not sure what you mean by 'converting' the databases.  You can also access all of these objects in their collections

CurrentDB.Tabledefs
CurrentDB.Querydefs
CurrentDB.Containers!Forms
CurrentDB.Containers!Reports
CurrentDB.Containers!Modules
CurrentDB.Containers!Scripts  '(Macros)
0
 

Author Comment

by:skyberg
ID: 6492775
Mr cjswimmer!
By convert I mean transfering objects from say a -97
version to an empty (new) -2000 version app.
When I've got a job of converting quite a number of apps,
I am very tempted to do that in an automated manner
(if possible). I have made a tool for just that.
But as You point out, it may be neccesary to go into
the interior of the bases, adressing the different objects
just the way You describe above.
Unless I find a better way, I may do just that.

I'll be back with a conclusion in a few days.

Jan
0
 
LVL 6

Expert Comment

by:cjswimmer
ID: 6493305
If you open an Access 97 database with Access 2000, you will prompted to have the database converted automatically for you.  While this technique is not always error-free, it does save a tremendous amount of work and there are articles available on what situations can occur when you have Access do the conversion for you.

0
 

Author Comment

by:skyberg
ID: 6493734
Yes, I know that.
Using that technique, it sure is best to do it manually.
There is however another approach to the problem; namely
1) Start Access v-2000 creating an empty base.
2) Importing objects from the -97 base.
3) Manually checking for errors in References (compile).

Doing it this way, I have automated the prosess of
at least importing the table-objects.
In the case at hand, the bases are very simple, with no
relationships and all in one file.
The problem is; the number of files.
Of couse there may be permission-problems which will be
seen on the screenm during the batch-run.

Jan
0
 

Author Comment

by:skyberg
ID: 6505513
Hi mr cjswimmer !
Here are Your points for giving the best info.

Jan
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now