Re: Help with Docmd Open form
- From: RoyVidar <roy_vidarNOSPAM@xxxxxxxx>
- Date: Tue, 12 Dec 2006 16:54:43 +0100
"Tony Williams" <tw@xxxxxxxxxxx> wrote in message
<Or9cgMgHHHA.2456@xxxxxxxxxxxxxxxxxxxx>:
I have a form called "frmprojects" on which is a combo box
"cmbproject" and a command button "cmdopen" I want to open a form
"Time Cards 2" where the value of "cmbproject" is equal to the value
of "Projectname" on the subform "Clientsubform" which is a subform
of "Time card 2" I have used this code but I get an error message
that says "Syntax error"
Private Sub cmdOpen_Click()
Docmd.OpenForm ("Time cards
2",acNormal,,Forms![frmprojects].[cmbproject] = Forms!["Time card
2"]![Client subform].Form![Projectname]) End Sub
Can anyone help me with the syntax here, I thought I'd followed the
proper convention.
Thanks
Tony
1 - drop the parenthesis
2 - the usual recommandations, are to avoid spaces and special
characters in the name of objects, though I think it should
be OK without [brackets] in the OpenForm method of the DoCmd
object
3 - the where condition should be a *valid* SQL WHERE clause,
without the keyword WHERE, which would mean including a field
name from the form recordsource
Most of this, you would probably have found out by hitting F1 while
the cursor is within the OpenForm keyword in VBE, where there is at
least one sample
Docmd.OpenForm "Time cards 2",,, "Projectname = '" & _
Me!Clientsubform.Form!cmbproject & "'"
From what you say, you seem to want use a criterion received from asubform of the form you want to open. I don't think that will work,
but do tweak a little with the where condition of the above
suggestion, where I assume the subform is a subform residing on the
current form (Me) in stead.
--
Roy-Vidar
.
- Follow-Ups:
- Re: Help with Docmd Open form
- From: Tony Williams
- Re: Help with Docmd Open form
- References:
- Help with Docmd Open form
- From: Tony Williams
- Help with Docmd Open form
- Prev by Date: Re: Raise event in Access subform?
- Next by Date: Margin listbox to left or Right
- Previous by thread: Help with Docmd Open form
- Next by thread: Re: Help with Docmd Open form
- Index(es):