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 October 21st, 2010, 10:56 PM
bph bph is offline
Friend of Wrox
 
Join Date: Dec 2003
Posts: 102
Thanks: 2
Thanked 0 Times in 0 Posts
Default The search key was not found

Hi,

I have a problem with and excel 2007 import into Access 2007. I have setup a saved import in Access named Import_Weekly_Terms which appends records to a table in the database from an Excel file named Weekly_Terms.

When I set up the savedimport it runs fine the first time. Then I put another Weekly_Terms file in place of the first one, same columns in spreadsheet, same directory and so forth.

When I run click the button I get Runtime Error 3709. "The search key was not found in any record."

here's the code behind the command button which executes on click:

Dim Msg, Style, Title, Response, CheckInit 'Declare variables.
Msg = "Do you want to run the Weekly Terms Import?" 'Message.
Style = vbYesNo + vbExclamation + vbDefaultButton2 'Define buttons.
Title = "Warning!" 'Define title of dialogue box.
Response = MsgBox(Msg, Style, Title)
If Response = vbYes Then
DoCmd.SetWarnings False
DoCmd.RunSQL "Delete * from tblWeekly_Terms"
DoCmd.RunSQL "Delete * from tblWT_Temp"
DoCmd.RunSavedImportExport "Import_Weekly_Terms" (debug takes me here)
ElseIf Response = vbNo Then
DoCmd.CloseDatabase
End If

Any thoughts? Thanks, bph
 
Old October 22nd, 2010, 10:10 AM
bph bph is offline
Friend of Wrox
 
Join Date: Dec 2003
Posts: 102
Thanks: 2
Thanked 0 Times in 0 Posts
Default

Man O Man, I'm a knucklehead!!

After 9 hours of banging my head off the wall, I found the problem. The excel file that is created and sent to us had the correct filename, but a different worksheet name than what we had set up the saved import with.

So, instead of 'Sheet1', the name of the worksheet was 'terms_1-212010'. When the savedimport looked for Sheet1, I got no search key found error. Geez!

Hope this helps someone someday.

cheers, bph





Similar Threads
Thread Thread Starter Forum Replies Last Post
Foreign key not updating with Primary key xavier1945 BOOK: Access 2003 VBA Programmer's Reference 2 July 4th, 2007 09:48 PM
Using key() and <xsl:key> freddy XSLT 2 January 18th, 2007 08:55 PM
<bean:message key="PNR.INPUT"/> key has null value warsha_14 Struts 1 November 13th, 2006 07:26 AM
classname 'SiteMap' and key 'Home' was not found. papalolo22 BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 1 October 19th, 2006 09:14 PM
TAB KEY working together KEY PRESS event thomaz C# 4 August 20th, 2006 02:47 PM





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