dbTalk Databases Forums  

Row Source SQL query question.

comp.databases.ms-access comp.databases.ms-access


Discuss Row Source SQL query question. in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Karen Hill
 
Posts: n/a

Default Row Source SQL query question. - 07-08-2005 , 05:08 PM






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.


Reply With Quote
  #2  
Old   
Salad
 
Posts: n/a

Default Re: Row Source SQL query question. - 07-08-2005 , 07:41 PM






Karen Hill wrote:

Quote:
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


Reply With Quote
  #3  
Old   
Larry Linson
 
Posts: n/a

Default Re: Row Source SQL query question. - 07-08-2005 , 10:25 PM




"Karen Hill" <karen_hill22 (AT) yahoo (DOT) com> wrote

Quote:
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




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.