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 December 2nd, 2007, 07:18 AM
Registered User
 
Join Date: Mar 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Expressions in query criteria

Hi all, hope you guys are well....

Some help if you have a moment..

A simple access db to filter some data... this will be sent offsite so needs to be bullet proof. Or rather stupid proof!

*created a query to manage the data - fine
*created a few queries to use as lookup in a combo box that populates a single line table with the criteria for filtering the data. - fine
*now back in my main data query i show the table with the info i want to filter on - ok
*add to criteria iif([LenderName]=null,"*",[LenderName]) - simple you would think, have tried so many work arounds and have not cracked it. The only thing that sort of works is "In ([LenderName])" but that doesnt give me an option to view all data if none is selected!!!

2nd thing is I have the two forms brought into a third form as subforms. i can select the data in the first subform but cant refreshed the continuous form to show the results without closing and reopening it... any ideas?

Thx for help D
 
Old December 3rd, 2007, 09:16 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Where are these criteria? I would put them on the form and pass them in the WHERE clause of the DoCmd.OpenReport or OpenForm event like this, assuming the Vendor Combo takes an integer (PK):

Dim sLink As String
Dim sDoc As String

If IsNull(Me.cboVendorName) Or Me.cboVendorName = "" Then
   sLink = ""
Else
   sLink = "[VendorName] = " & Me.cboVendorName
End If

sDoc = "rptMyReportName"

DoCmd.OpenReport sDoc, acPreview, , sLink

Did that help?


mmcdonal

Look it up at: http://wrox.books24x7.com
 
Old December 13th, 2007, 04:33 PM
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

A slight modification if Vendor Name is text.

Dim sLink As String
Dim sDoc As String

If Len(Trim(Nz(Me.cboVendorName, ""))) = 0 Then
sLink = ""
Else
sLink = "[VendorName] = '" & Me.cboVendorName & "'"
End If

sDoc = "rptMyReportName"

DoCmd.OpenReport sDoc, acPreview, , sLink


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





Similar Threads
Thread Thread Starter Forum Replies Last Post
Conditional criteria in query dfuas Access VBA 1 January 21st, 2006 03:46 AM
Conditional criteria in query dfuas Access 1 January 21st, 2006 03:39 AM
Criteria in Query lryckman Access 1 June 23rd, 2004 11:11 AM
Query Criteria Clive Astley Access 4 March 25th, 2004 03:27 AM
Append Query Criteria Ben Access 1 January 21st, 2004 07:24 AM





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