PC Review


Reply
Thread Tools Rate Thread

Criteria when opening form

 
 
CharlieNews
Guest
Posts: n/a
 
      15th Jan 2011
Hi,

I have a button with the following command:

Private Sub OpenQuoteDetails_Click()
On Error GoTo Err_OpenQuoteDetails_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Quote Details"

stLinkCriteria = "[Order]=" & Me![Order Number Combo]
DoCmd.OpenForm stDocName, , , stLinkCriteria


Exit_OpenQuoteDetails_Click:
Exit Sub

Err_OpenQuoteDetails_Click:
MsgBox Err.Description
Resume Exit_OpenQuoteDetails_Click

End Sub

I would like to add and OR option to the link criteria to:
stLinkCriteria = "[Quote]=" & Me![QuoteNumber]

Can anyone help?

Thanks in advance.

Charlie


 
Reply With Quote
 
 
 
 
John W. Vinson
Guest
Posts: n/a
 
      15th Jan 2011
On Sat, 15 Jan 2011 17:16:59 -0000, "CharlieNews"
<(E-Mail Removed)> wrote:

>I would like to add and OR option to the link criteria to:
>stLinkCriteria = "[Quote]=" & Me![QuoteNumber]


Sure. The stLinkCriteria variable just needs to contain a text string
containing a valid SQL WHERE clause (without the word WHERE). You can see how
such a string is constructed by just using the query design window to build
the query you want, and then viewing this query in SQL view; see what's after
the keyword WHERE.

In this case it would be:

stDocName = "Quote Details"

stLinkCriteria = "[Order]=" & Me![Order Number Combo] & " OR [Quote] = " _
& Me![QuoteNumber]
DoCmd.OpenForm stDocName, , , stLinkCriteria

This string should look like

[Order]=123 OR [Quote] = 36

if you use Debug to step through the code and view the stLinkCriteria value.
--

John W. Vinson [MVP]
Microsoft's replacements for these newsgroups:
http://social.msdn.microsoft.com/For...-US/accessdev/
http://social.answers.microsoft.com/.../en-US/addbuz/
and see also http://www.utteraccess.com
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Opening a form with two filter criteria John Constantine Microsoft Access 2 6th Jul 2011 04:08 PM
Opening one form based on 2 criteria in another form kejo41 Microsoft Access Forms 0 18th Feb 2010 05:38 AM
Re: Criteria for opening form from a different subform Crystal (strive4peace) Microsoft Access Forms 11 5th Dec 2009 06:23 AM
Opening form using 2 criteria Naz Microsoft Access VBA Modules 9 2nd Sep 2009 11:38 PM
Criteria for opening a form based on a value in another form's subform seaton via AccessMonster.com Microsoft Access Form Coding 2 11th Jul 2007 01:40 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:38 AM.