473,399 Members | 3,656 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Using form criteria in ADP view?

Hi All,

Is it possible to use form criteria in a query / view in an Access
2003 ADP with SQL Server as the backend?

ie something like:

select * from mytable where recid = forms![frm_myform]![recid]

I'm trying to do something like this as the basis for a subform but I
get a syntax error because of the existence of the "!" characters.

Any help appreciated!

Much warmth,

Murray
Nov 12 '05 #1
5 4925
No, but there is a similar trick you can do with ADPs. If you create a stored
procedure to use as the Row Source of a combo or list box, and the stored
procedure takes a parameter with the same name (except for the additional
required @ sign) as a control on the same form, Access will automatically pass
the control's value to the stored procedure's parameter.

The same trick works with subforms, too. If the subform's Record Source is a
stored procedure, and the form has a control with the same name as a paramter
of the stored procedure, it will be automatically passed.

On Wed, 05 May 2004 14:44:15 GMT, M Wells <pl**********@planetthoughtful.org>
wrote:
Hi All,

Is it possible to use form criteria in a query / view in an Access
2003 ADP with SQL Server as the backend?

ie something like:

select * from mytable where recid = forms![frm_myform]![recid]

I'm trying to do something like this as the basis for a subform but I
get a syntax error because of the existence of the "!" characters.

Any help appreciated!

Much warmth,

Murray


Nov 12 '05 #2
You can't use a forms ref directly in the sql..but you can resolve it.

So, you can stuff the sql directly into the forms reocrdsouce.

dim strSql as string

strSql = "select * from mytable where recid = " & forms![frm_myform]![recid]

me.MySubForm.Form.RecordSouce = strSql
--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pl******************@msn.com
http://www.attcanada.net/~kallal.msn

Nov 12 '05 #3
Ah!

Thanks Steve, another thing I was wondering about was how to pass
multiple criteria to a stored procedure from a form.

I think what you've written below solves that issue for me.

However, do stored procedures allow criteria to be passed when they
involve subqueries? I've noticed that functions don't seem to allow
you to pass criteria if the function involves a subquery. Seems like
an odd ommision, since just about every other subform I create is
doing something like, show all available records that aren't currently
included in another subform's recordset. With some playing around, I
can usually write the sql so that it doesn't use a subquery, but it's
a lot easier to simply use a 'where column not in (select column from'
statement.

Thanks for this tip!

Much warmth,

Murray
On Wed, 05 May 2004 16:53:37 GMT, Steve Jorgensen
<no****@nospam.nospam> wrote:
No, but there is a similar trick you can do with ADPs. If you create a stored
procedure to use as the Row Source of a combo or list box, and the stored
procedure takes a parameter with the same name (except for the additional
required @ sign) as a control on the same form, Access will automatically pass
the control's value to the stored procedure's parameter.

The same trick works with subforms, too. If the subform's Record Source is a
stored procedure, and the form has a control with the same name as a paramter
of the stored procedure, it will be automatically passed.

On Wed, 05 May 2004 14:44:15 GMT, M Wells <pl**********@planetthoughtful.org>
wrote:
Hi All,

Is it possible to use form criteria in a query / view in an Access
2003 ADP with SQL Server as the backend?

ie something like:

select * from mytable where recid = forms![frm_myform]![recid]

I'm trying to do something like this as the basis for a subform but I
get a syntax error because of the existence of the "!" characters.

Any help appreciated!

Much warmth,

Murray


Nov 12 '05 #4
"M Wells" <pl**********@planetthoughtful.org> wrote in message
news:b9********************************@4ax.com...
Ah!

Thanks Steve, another thing I was wondering about was how to pass
multiple criteria to a stored procedure from a form.

If the form is bound to the procedure use the forms' InputParameters
property setting:

I think what you've written below solves that issue for me.

However, do stored procedures allow criteria to be passed when they
involve subqueries?
AFAIK the structure of the procedure has no influence on whether or not it
will accept parameters.
I've noticed that functions don't seem to allow
you to pass criteria if the function involves a subquery.

I've never seen this. Do you have a script to repro this problem?
I don't even know whether you can bind a function to a form - I've heard
that you can but not sure why you would ever want to.

Nov 12 '05 #5
On Wed, 12 May 2004 09:51:07 -0400, "John Winterbottom"
<as******@hotmail.com> wrote:
I've noticed that functions don't seem to allow
you to pass criteria if the function involves a subquery.

I've never seen this. Do you have a script to repro this problem?
I don't even know whether you can bind a function to a form - I've heard
that you can but not sure why you would ever want to.


Hi John,

Using a function to return a recordset to a form using form criteria
is described in the following KnowledgeBase article:

http://support.microsoft.com/default...b;en-us;278400

Given that this was the recommendation Microsoft made, this is what I
did.

However, attempting to include an @variable in a function with a
subquery returns the error message I described in my original post.

Much warmth,

Murray
Nov 12 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Steve | last post by:
Form FrmRestock's recordsource is QryFrmRestock. The TransactionDate field's criteria is set ats: Forms!FrmRestock!LastXDays. LastXDays on the form is a combobox where the selections are 30, 60...
0
by: CSDunn | last post by:
Hello, I have a problem with field filtering between an Access 2000 Project form (the application is called CELDT), and the report that shows the results of the filter. Both the form and the...
3
by: dskillingstad | last post by:
I'd appreciate any help I can get. I'm not sure what I'm doing wrong, but.... I've searched these groups for some solutions but no luck. I have an unbound form (frmSearch), with several unbound...
8
by: | last post by:
hi, i have a form on which a user can choose specific criteria such as dates etc, in order to filter the report that is called from the form. i do this by using the Where section of the...
7
by: keliie | last post by:
Hello Just a quick question that I've spent a few hours trying to solve with no luck (although one would think this should be fairly easy). I have a form with a subform. The subform is based...
3
by: google | last post by:
I'm developing an application for use within my company in Access 2003. I'm new to '03, the application I did for my former employer was in '97. The two applications have similar functionality...
2
by: fstenoughsnoopy | last post by:
I have a customer order database and I need to pull a customers information, ie first name, last name, address, city, state, zip, phone, etc, into the oder table. i don't know how to go about...
2
by: Mark Roughton | last post by:
I have a form where the users need to view records for various criteria, one of which is a date field on which they may wish to view all related data for the selected date, for all dates upto and...
8
by: hollinshead | last post by:
Hi there i have bit of an issue. i haver this database that is purely used for searching records under certain criteria. This criteria is chosen by the user on a form using list boxes and combo...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.