Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 518
  • Last Modified:

On the use of "SendKeys"

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
skyberg
Asked:
skyberg
1 Solution
 
Ryan ChongCommented:
Hi skyberg,

So maybe you need to call that particular Sub as:

Call Command1_Click()
0
 
maatthiasCommented:
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
 
cjswimmerCommented:
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
nico5038Commented:
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
 
skybergAuthor Commented:
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
 
cjswimmerCommented:
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
 
skybergAuthor Commented:
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
 
cjswimmerCommented:
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
 
skybergAuthor Commented:
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
 
skybergAuthor Commented:
Hi mr cjswimmer !
Here are Your points for giving the best info.

Jan
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now