By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,493 Members | 1,186 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,493 IT Pros & Developers. It's quick & easy.

Row Source SQL query question.

P: n/a
How do I include a where clause that contains a form value in a Row
Source SQL query? This is in the form properities under DATA.

SELECT [Categories].[CategoryName] FROM Categories WHERE Catogories.id
= Me![id];

The "Me![id]" is a form control.

Nov 13 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Karen Hill wrote:
How do I include a where clause that contains a form value in a Row
Source SQL query? This is in the form properities under DATA.

SELECT [Categories].[CategoryName] FROM Categories WHERE Catogories.id
= Me![id];

The "Me![id]" is a form control.

Usually you do something like this
Dim strSQL As STring
dim rst As Recordset
strSQL = "SELECT [Categories].[CategoryName] " & _
"FROM Categories " & _
"WHERE Catogories.id = " & Me![id];
set rst = currentdb.openrecordset(strSQL,dbopendynaset)

If you are in the query builder, you need to know the name of the form
SELECT [Categories].[CategoryName] _
FROM Categories _
WHERE Catogories.id = Forms!YourFormName!ID
Nov 13 '05 #2

P: n/a

"Karen Hill" <ka**********@yahoo.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
How do I include a where clause that contains a form value in a Row
Source SQL query? This is in the form properities under DATA.

SELECT [Categories].[CategoryName] FROM Categories WHERE Catogories.id
= Me![id];

The "Me![id]" is a form control.


The "Me" shorcut notation can only be used in VBA code in the Form's or
Report's module. To use such a reference in RowSource (or in an expression
in a Control's ControlSource), you have to use the fully-qualified
reference, such as

Forms!frmYourForm!id

Larry Linson
Microsoft Access MVP
Nov 13 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.