A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

stLinkCriteria - Multiple criteria



 
 
Thread Tools Display Modes
  #1  
Old November 8th, 2005, 04:46 AM
Rick
external usenet poster
 
Posts: n/a
Default stLinkCriteria - Multiple criteria

Greetings,

I have the following code and I get a "The OpenForm action was
cancelled" message.

Private Sub btnThisWeeksGames_Click()

On Error GoTo Err_btnThisWeeksGames_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmGames"

stLinkCriteria = "[Season]='" & Me![cboSeasonID] & "' AND [Week]='"
& Me![cboWeek] & "'"
Debug.Print stLinkCriteria
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_btnThisWeeksGames_Click:
Exit Sub

Err_btnThisWeeksGames_Click:
MsgBox Err.Description
Resume Exit_btnThisWeeksGames_Click

End Sub


The Debug.Print statement yields [Season]='2005/2006' AND [Week]='9'


If I change it to stLinkCriteria = "[Season]='" & Me![cboSeasonID] &
"'"
it works just fine.

Please help a dumb Texan.

  #2  
Old November 8th, 2005, 06:02 AM
fredg
external usenet poster
 
Posts: n/a
Default stLinkCriteria - Multiple criteria

On 7 Nov 2005 20:46:18 -0800, Rick wrote:

Greetings,

I have the following code and I get a "The OpenForm action was
cancelled" message.

Private Sub btnThisWeeksGames_Click()

On Error GoTo Err_btnThisWeeksGames_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmGames"

stLinkCriteria = "[Season]='" & Me![cboSeasonID] & "' AND [Week]='"
& Me![cboWeek] & "'"
Debug.Print stLinkCriteria
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_btnThisWeeksGames_Click:
Exit Sub

Err_btnThisWeeksGames_Click:
MsgBox Err.Description
Resume Exit_btnThisWeeksGames_Click

End Sub

The Debug.Print statement yields [Season]='2005/2006' AND [Week]='9'

If I change it to stLinkCriteria = "[Season]='" & Me![cboSeasonID] &
"'"
it works just fine.

Please help a dumb Texan.


What is the Datatype of the [Week] field?
Probably it's a number, not text, so try:
stLinkCriteria = "[Season]='" & Me![cboSeasonID] & "' AND [Week]= "
& Me![cboWeek]

Your debug statement should then read:
[Season]='2005/2006' AND [Week]=9

--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
  #3  
Old November 8th, 2005, 01:09 PM
Klatuu
external usenet poster
 
Posts: n/a
Default stLinkCriteria - Multiple criteria

Rick,
I think fredg's answer will solve your problem, but you being a Texan, I
feel compelled to point something out to you. Never ask anyone where they
are from. If they are from Texas, they will tell you. If they are not,
there is no sense in embarresing them.

"Rick" wrote:

Greetings,

I have the following code and I get a "The OpenForm action was
cancelled" message.

Private Sub btnThisWeeksGames_Click()

On Error GoTo Err_btnThisWeeksGames_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmGames"

stLinkCriteria = "[Season]='" & Me![cboSeasonID] & "' AND [Week]='"
& Me![cboWeek] & "'"
Debug.Print stLinkCriteria
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_btnThisWeeksGames_Click:
Exit Sub

Err_btnThisWeeksGames_Click:
MsgBox Err.Description
Resume Exit_btnThisWeeksGames_Click

End Sub


The Debug.Print statement yields [Season]='2005/2006' AND [Week]='9'


If I change it to stLinkCriteria = "[Season]='" & Me![cboSeasonID] &
"'"
it works just fine.

Please help a dumb Texan.


  #4  
Old November 8th, 2005, 03:55 PM
Rick
external usenet poster
 
Posts: n/a
Default stLinkCriteria - Multiple criteria

Fred,

It worked perfectly. Not only have you solved my problem, you taught
me something... and that is the most thing you could have done.
Thank you very much!!!

Rick aka A little less dumb Texan

  #5  
Old December 12th, 2005, 05:00 AM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default stLinkCriteria - Multiple criteria

Hello,

I'm having a similar problem but I'm trying to include a multi-list bos
selection to my criteria.

I'm at the end of my rope trying to make this work.

can anyone get me a push in the right dirrection?

I'm using the following code to make the multi-list selection

If Me!TradeSelection.ItemsSelected.Count 0 Then
For Each varTradeItem In Me!TradeSelection.ItemsSelected
strTradeCriteria = strTradeCriteria & "Trade = " & Chr(34) &
Me!TradeSelection.ItemData(varTradeItem) & Chr(34) & "OR "

Next varTradeItem
strTradeCriteria = Left(strTradeCriteria, Len(strTradeCriteria) - 3)
Else
MsgBox "You have not made a selection" , vbExclamation, "Nothing to
find!"
End If

Then I'm trying to add another field on the form called SBKG to the
LinkCriteria

stLinkCriteria = "[SBKG]= '" & Me![cboSBKG] & "' And [Trade]= '" &
strTradeCriteria & "'"

the goal is to open the following report but I can't figure-out what I doing
wrong

DoCmd.OpenReport strDocName, acViewPreview, , stLinkCriteria

I would appreciate any help you can provide

Thank you


 




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple Criteria IF Nesting BethB Worksheet Functions 2 May 17th, 2005 12:14 AM
Criteria on multiple fields tijut Running & Setting Up Queries 2 May 9th, 2005 07:54 PM
Complex query criteria - desperate appeal Ted Allen Running & Setting Up Queries 5 November 17th, 2004 06:14 PM
Multiple Many-To-Many Tables Tom Database Design 7 May 15th, 2004 03:47 AM
SUMIF w/ Multiple criteria?? Jana Worksheet Functions 3 April 17th, 2004 10:26 AM


All times are GMT +1. The time now is 06:05 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.