Learn how to a build a cloud-first strategyRegister Now

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

sendkeys funny in access VB with runcommand accmdfind

Access 2002 (XP)

I have the following code to try and persuade the find dialog box to start with correct settings using sendkeys. It works (sometimes but also sets caps lock on!
Come on, Bill gates! Any ideas?

"
    ' do the deed
    Me.this.SetFocus             '!!! whatever the first field is for any form
    SendKeys "%ha%e%rd"   ' any part of form and field and looking down, from MS documentation
    Application.RunCommand acCmdFind

"

Thanks.
0
Peborgh
Asked:
Peborgh
  • 3
  • 2
2 Solutions
 
Leigh PurvisDatabase DeveloperCommented:
That's the *classic* bug with Sendkeys.

http://www.mvps.org/access/api/api0046.htm
0
 
PeborghAuthor Commented:
Err...
I pinched the code, incorporated into my app, compiled OK:

"
    ' do the deed
    Me.this.SetFocus                            '!!! whatever the (first) field is for any form
    FsendKeys "%ha%e%rd"                 ' any part of field and going down (uses a "safe" Sendkeys)
    Application.RunCommand acCmdFind

"
... and it behaves just like the original SendKeys, setting caps lock ON.

What am I missing?

Many thanks,

peter
0
 
Leigh PurvisDatabase DeveloperCommented:
Caps lock wasn't already on?
I assume the API is still valid under XP (was first published some time ago - but would have come to light easily by now otherwise).

I've never used it personally - as I don't use Sendkeys :-)
0
Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

 
PeborghAuthor Commented:
Anyone out there know of an alternative, specifiable find/findNext proc/func?

Thanks.
0
 
harfangCommented:
Hello,

A home-grown "Find"?

    Dim strFind As String
    strFind = InputBox("What now?", "Find")
    If strFind = "" Then Exit Sub
    strFind = Replace(strFind, "'", "''")
    With Me.RecordsetClone
        ' Find first (see below for findnext)
        .FindFirst "YourSearchField Like '*" & strFind & "*'"
        If .NoMatch Then MsgBox "huh?": Exit Sub
        Me.Bookmark = .Bookmark
    End With

Find next:
        .Bookmark = Me.Bookmark
        .FindNext "YourSearchField Like '*" & strFind & "*'"

To have a combination of find first / find next buttons, the best is to store the search criteria in a global variable as a whole:

    gstrCriteria = "YourSearchField Like '*" & strFind & "*'"

Finally, if you feel adventurous, it's quite easy to rewrite the entire "Find" dialog as a custom pop-up form.

Cheers!
(°v°)
0
 
PeborghAuthor Commented:
Getting back to the subject in hand, mySendKeys does work!! I was using Fsendkeys and that acted in the uncorrected way. Blame Bill gates.
So thanks to LPurvis for his help on sendkeys and (oVo) for his finding substiture - that knowledge was useful also.

peter
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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