View Full Version : Check my code


matthewnsarah07
11-21-2008, 07:47 AM
Hi

I am using the following code to open a another form but the Where criteria is not filtering correctly - all field and form names are correct and the subform where the button is, is a continuous form

Hope someone can point out what i have done wrong here


Private Sub Command21_Click()
Dim strForm As String
Select Case Me.Accept_etc
Case Is = "Awaiting TM Approval"
strForm = "frmeditrequest"
DoCmd.OpenForm strForm, acNormal, , [Request Number] = [Forms]![frmmain]![frmmainsub].[Form]![Request Number]
Case Else
MsgBox "This request can no longer be altered", vbOKOnly
End Select
End Sub

pbaldy
11-21-2008, 07:52 AM
You should concatenate the form reference. Here's a sample of the 3 syntax possibilities:

http://www.baldyweb.com/wherecondition.htm

matthewnsarah07
11-21-2008, 08:07 AM
Thanks for the advice

Gave this a try using the syntax for numerical values adding " & before the rest of the condition. I noticed an " appeared at the end of my condition aswell (appeared automatically) and now no results are shown at all

Any ideas?

pbaldy
11-21-2008, 08:10 AM
What does that line look like now?

matthewnsarah07
11-21-2008, 08:21 AM
DoCmd.OpenForm strForm, acNormal, , [Request Number] = " & [Forms]![frmmain]![frmmainsub].[Form]![Request Number]"

pbaldy
11-21-2008, 08:28 AM
You missed the quotes before the field name, which is why it added a set at the end. Try:

DoCmd.OpenForm strForm, acNormal, , "[Request Number] = " & [Forms]![frmmain]![frmmainsub].[Form]![Request Number]

matthewnsarah07
11-21-2008, 08:33 AM
Thanks for your help, thats sorted it

Matt