Open form containing fields of a record

F

faberk

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
 
M

Marshall Barton

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 & """"
 
F

faberk

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
 
M

Marshall Barton

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?
 
D

Douglas J. Steele

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
 
M

Marshall Barton

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 ;-)
 
D

Douglas J. Steele

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!
 

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