Criteria when opening form


C

CharlieNews

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 = "
=" & Me![QuoteNumber]

Can anyone help?

Thanks in advance.

Charlie
 
Ad

Advertisements

J

John W. Vinson

I would like to add and OR option to the link criteria to:
stLinkCriteria = "
=" & 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
= " _
& Me![QuoteNumber]
DoCmd.OpenForm stDocName, , , stLinkCriteria

This string should look like

[Order]=123 OR
= 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/Forums/en-US/accessdev/
http://social.answers.microsoft.com/Forums/en-US/addbuz/
and see also http://www.utteraccess.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top