Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 5th, 2006, 11:52 PM
Registered User
 
Join Date: Jun 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Please Help! - SendKeys

Hi!

Brand new user here!

Question:
I am trying to send keys after a "RunCommand acCmdInsertObject" line to press the 'Browse' button and then to navigate a root attachment folder for the record.

I have:
    RunCommand acCmdInsertObject
    Dim KeyString As String
    KeyString = DLookup("[FileLocation]", "tbl_FileLocations", "[Name]='" & "Database Folder" & "'") & "Attachments\IRS " & IRSNumber.Value
    SendKeys "%B"
    SendKeys KeyString
    SendKeys "~"

But it doesn't even get to ALT B (%B).

I've tried other combos and even adding a pause but I don't seem to get any keys to the 'Insert Object' dialog box.

Any ideas? Or is there a better way to reach my desired end result?
 
Old June 9th, 2006, 07:41 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

First, clean up your keystring statement. Is Database Folder a field or variable? If it is, then

KeyString = DLookup("[FileLocation]", "tbl_FileLocations", "[Name] = '" & Me.[Database Folder] & " Attachments\IRS " & Me.IRSNumber & "'")

for a field, or

KeyString = DLookup("[FileLocation]", "tbl_FileLocations", "[Name] = '" & DatabaseFolder & " Attachments\IRS " & Me.IRSNumber & "'"

for a variable you made up. If it's part of the folder (directory) name, then it's

KeyString = DLookup("[FileLocation]", "tbl_FileLocations", "[Name] = 'Database Folder Attachments\IRS " & Me.IRSNumber & "'"

Or did you mean

KeyString = DLookup("[FileLocation]", "tbl_FileLocations", "[Name] = 'Database Folder\Attachments\IRS " & Me.IRSNumber & "'"

Second, the use of SendKeys is dangerous. If you want to use SendKeys, note that it acts upon the ACTIVE window. Is the window with the BROWSE button really the active window at that point? If not, the ALT+B will occur elsewhere where the ALT+B means nothing.


Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division





Similar Threads
Thread Thread Starter Forum Replies Last Post
Sendkeys Add-In Problem tiabooks Excel VBA 0 November 6th, 2006 01:31 PM
How to avoid printing "1" after Sendkeys font45 Excel VBA 2 August 18th, 2006 05:21 PM
SendKeys wassa Access VBA 1 July 16th, 2006 02:55 AM
Problem with SendKeys while downloading a file desperado1306 Excel VBA 0 May 25th, 2006 12:05 PM
SendKeys.Send LCTRL ? ItshiBan VS.NET 2002/2003 0 September 4th, 2003 04:07 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.