Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > BOOK: Beginning Access VBA
|
BOOK: Beginning Access VBA
This is the forum to discuss the Wrox book Beginning Access 2002 VBA by Robert Smith, Dave Sussman, Ian Blackburn, John Colby, Mark Horner, Martin Reid, Paul Turley, Helmut Watson; ISBN: 9780764544026
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning 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 September 7th, 2004, 09:31 AM
Registered User
 
Join Date: Sep 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 8 VBA 2000: frmCriteria not working.

Hi,

I have tried to apply the following code from the book to my database.
I have managed to build successfully the tblResults. But when I select a criteria from the frmCriteria, I get the following runtime error: 3464: Data type mismatch in criteria expression.
The debugger is pointing at the following code:

Function BuildResultsTable(strSQL As String, _
                         strTableName As String, _
                         strRecordsAffected As String)
                        
Dim db As Database
Dim qdfAction As QueryDef

Set db = CurrentDb

On Error Resume Next
db.TableDefs.Delete strTableName
On Error GoTo 0

strSQL = Replace(strSQL, " FROM ", " INTO " & strTableName & " FROM ")
Set qdfAction = db.CreateQueryDef("", strSQL)
qdfAction.Execute dbFailOnError
strRecordsAffected = qdfAction.RecordsAffected
qdfAction.Close

BuildResultsTable = True

End Function

My table contains a Text data type as Primary key, which I have tried to addapt by changing the lngRecordsAffected from the book to strRecordsAffected, making sure that I would be consistent with it. Was it a mistake?
I am quite confused and would really appreciate some help.
Many Thanks,


Chris





Similar Threads
Thread Thread Starter Forum Replies Last Post
Access 2000 VBA Chapter 3 Problem Pauldowsett BOOK: Beginning Access VBA 3 January 30th, 2005 03:06 PM
Chapter 17 Beginning Access 2000 VBA gracechen19 BOOK: Beginning Access VBA 0 August 23rd, 2004 04:02 PM
VBA for Excel 2000...HELP! lhardesty Excel VBA 2 August 20th, 2004 09:08 AM
Beginning Access 2000 VBA Chapter 6: List Boxes greencw BOOK: Beginning Access VBA 1 June 13th, 2004 08:16 PM





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