Open form containing fields of a record

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I posed this question some time ago and just got around to testing the
suggestion by one of the MVP's here. I can't get it to work. Could someone
help me please? It fails on the wherecondition. According to the online
help for the "openform" method, the where condition is looking for a valid
SQL statement. Im not sure how to proceed. Previous question and response,
as follows:
I wish to double click on a record contained in a subform in continuous forms >view. The record's fields would then displayed in another form,
changes Could then be applied to selected fields of the
record.


Use the OpenForm method's WhereCondition argument to open
the form with the selected record. If you open the form in
Dialog mode, your code will stop executing until the form is
closed, at which time you can requery the subform:

DoCmd.OpenForm "anotherform", _
WhereCondition:= "Key = " & Me.txtKey, _
WindowMode:= acDialog
Me.Requery
 
Help says the WhereCondition argument is an SQL WHERE CLAUSE
without the word where.

Note that is the field you're filtering on is a Text type
field, the value you're searching for must be enclosed in
quotes:

WhereCondition:= "Key = """ & Me.txtKey & """"
 
Marsh,

I can't get this to work:

Private Sub ChildDescr_DblClick(Cancel As Integer)

DoCmd.OpenForm "form1", _
WhereCondition:="Key = """ & Me.txtKey & """", _
Windowmode:=acDialog
Me.Requery

End Sub

What am I doing wrong?
T
hanks,
Kevin


Marshall Barton said:
Help says the WhereCondition argument is an SQL WHERE CLAUSE
without the word where.

Note that is the field you're filtering on is a Text type
field, the value you're searching for must be enclosed in
quotes:

WhereCondition:= "Key = """ & Me.txtKey & """"
--
Marsh
MVP [MS Access]

I posed this question some time ago and just got around to testing the
suggestion by one of the MVP's here. I can't get it to work. Could someone
help me please? It fails on the wherecondition. According to the online
help for the "openform" method, the where condition is looking for a valid
SQL statement. Im not sure how to proceed. Previous question and response,
as follows:



Use the OpenForm method's WhereCondition argument to open
the form with the selected record. If you open the form in
Dialog mode, your code will stop executing until the form is
closed, at which time you can requery the subform:

DoCmd.OpenForm "anotherform", _
WhereCondition:= "Key = " & Me.txtKey, _
WindowMode:= acDialog
Me.Requery
 
faberk said:
I can't get this to work:

Private Sub ChildDescr_DblClick(Cancel As Integer)

DoCmd.OpenForm "form1", _
WhereCondition:="Key = """ & Me.txtKey & """", _
Windowmode:=acDialog
Me.Requery

End Sub

What am I doing wrong?


That's a syntactically valid statement, so I have no idea
what's wrong.

What symptoms are you seeing?
 
Marshall Barton said:
That's a syntactically valid statement, so I have no idea
what's wrong.

What symptoms are you seeing?

Actually, I'm not sure it is syntactically valid, Marsh. I thought that if
you passed any named variables, all of them had to be named. See whether the
following works:

DoCmd.OpenForm FormName:="form1", _
WhereCondition:="Key = """ & Me.txtKey & """", _
Windowmode:=acDialog
 
Douglas said:
Actually, I'm not sure it is syntactically valid, Marsh. I thought that if
you passed any named variables, all of them had to be named. See whether the
following works:

DoCmd.OpenForm FormName:="form1", _
WhereCondition:="Key = """ & Me.txtKey & """", _
Windowmode:=acDialog


You raise a good point, Doug, so I went back to check Help.
Surprise! No mention of what happens when you mix
positional and named arguments (even back to A97 Help).

I guess I was relying on my experience in compiler design
and with other languages. Anyway, I tested it and the VB
folks got it right ;-)

You can use positional arguments up to the point where you
use a named argument. After the first named argument, any
remaining arguments must also be named.

Checking back in some of my old apps, I find that I've been
following this practice all along without giving it a
thought.

Glad you brought it up, it's always nice to know what I'm
doing ;-)
 
Marshall Barton said:
You raise a good point, Doug, so I went back to check Help.
Surprise! No mention of what happens when you mix
positional and named arguments (even back to A97 Help).

I guess I was relying on my experience in compiler design
and with other languages. Anyway, I tested it and the VB
folks got it right ;-)

You can use positional arguments up to the point where you
use a named argument. After the first named argument, any
remaining arguments must also be named.

Checking back in some of my old apps, I find that I've been
following this practice all along without giving it a
thought.

Glad you brought it up, it's always nice to know what I'm
doing ;-)

Thanks for checking. (I was too lazy...). Sorry I doubted you!
 
Back
Top