Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access 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 August 4th, 2004, 12:53 AM
Registered User
 
Join Date: Dec 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default HEEELP!!! - strWhere Problem with DoCmd.OpenReport

Hi,

This should be very simple, but I can't make it work.

I'm trying to open a report from a form using DoCmd.OpenReport and two criteria (choosing records that have student names that match two possibilities).

It works with one criteria, as follows:

Dim strWhere as String

strWhere = "[Student] = '" & Me.StudentName1 & "'"

DoCmd.OpenReport stDocName, acPreview, , strWhere

The above seems to work perfectly fine.

However, when I try to go to two criteria, I get errors. For example, the following does not work:

Dim strWhere1 as String
Dim strWhere2 as String

strWhere1 = "[Student] = '" & Me.StudentName1 & "'"
strWhere2 = strWhere1 & " And [Student] = '" & Me.StudentName2 & "'"

DoCmd. OpenReport stDocName, acPreview, , strWhere2

The above does not work. I've tried changing it a bunch of different ways, based on dozens of examples I got off the Internet, but nothing works.

I'm pretty new to VBA. Does anyone know what I'm doing wrong?

Thanks.

Henry


 
Old August 4th, 2004, 01:07 AM
Registered User
 
Join Date: Dec 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yikes!

Obviously, I needed to be using an Or, not an And.

Henry






Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with DoCmd.Printout (Access2003) John Deutsch Access VBA 4 January 22nd, 2008 12:45 PM
Docmd.Openform problem mkobulni Access VBA 7 August 29th, 2007 09:05 AM
heeelp!! viktorius C# 2 February 12th, 2006 07:28 PM
DoCmd.FindRecord problem hottnikks_79 Access VBA 1 August 9th, 2005 07:58 AM
docmd.findrecord problem 02153246XX Access VBA 0 October 27th, 2003 01:58 AM





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