Solved

On the use of "SendKeys"

Posted on 2001-09-18
10
491 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 50

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
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
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
 
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
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 …
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

789 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