stLinkCriteria - Multiple criteria

R

Rick

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.
 
F

fredg

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
 
K

Klatuu

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.
 
R

Rick

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
 

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