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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|
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 |