select query

B

bijan

Hi all,
I have a form with four text box , one Cmdbutton and one subform related to
my table within four text feilds. What I need to do is: If user fill each/all
text boxes with it's criteria full keyword or partial of keyword(widecard)
and press Cmdbutton ,any results(Records contains criterias) to be displaied
in subform.
Any help/Suggestion would be appreciate
 
A

Arvin Meyer [MVP]

You can write code using the BuildCriteria method, or much simpler, just use
the form references in the query criteria, like:

[Forms]![frmFormName]![txtBoxName]

You can either type them in or right-click in the query's criteria box and
choose Build.
 
B

bijan

Hi Arvin,
Thank you for suggestion, But I wonder how do that! I have put
Like [Forms]![DIC]![txt2] &"*" in Record source of subform (criteria of
dic.name)
It worked but,just when I run the form query ask me the parametr value.
I prefer write a VBA code in on_click a commandbutton to obtain criterias
from my textboxes and show records in my subform.
Please inform me where did I go wrong?
Thanks in advance
Arvin Meyer said:
You can write code using the BuildCriteria method, or much simpler, just use
the form references in the query criteria, like:

[Forms]![frmFormName]![txtBoxName]

You can either type them in or right-click in the query's criteria box and
choose Build.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

bijan said:
Hi all,
I have a form with four text box , one Cmdbutton and one subform related
to
my table within four text feilds. What I need to do is: If user fill
each/all
text boxes with it's criteria full keyword or partial of keyword(widecard)
and press Cmdbutton ,any results(Records contains criterias) to be
displaied
in subform.
Any help/Suggestion would be appreciate
 
A

Arvin Meyer [MVP]

In VBA code you need to define the parameters because the Jet Expression
Service is not running. Something like (aircode):

Dim db as DAO.Database
Dim qdef as DAO.Querydef
Dim rst as DAO.Recordset

Set db = DBEngine.OpenDatabase("<<path to your MDB>>")
Set qdef = db.Querydefs("<<Your Select statement>>")
qdef.Parameters![txt2] = [Forms]![DIC]![txt2]

Set rst = qdef.Recordset
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

bijan said:
Hi Arvin,
Thank you for suggestion, But I wonder how do that! I have put
Like [Forms]![DIC]![txt2] &"*" in Record source of subform (criteria of
dic.name)
It worked but,just when I run the form query ask me the parametr value.
I prefer write a VBA code in on_click a commandbutton to obtain
criterias
from my textboxes and show records in my subform.
Please inform me where did I go wrong?
Thanks in advance
Arvin Meyer said:
You can write code using the BuildCriteria method, or much simpler, just
use
the form references in the query criteria, like:

[Forms]![frmFormName]![txtBoxName]

You can either type them in or right-click in the query's criteria box
and
choose Build.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

bijan said:
Hi all,
I have a form with four text box , one Cmdbutton and one subform
related
to
my table within four text feilds. What I need to do is: If user fill
each/all
text boxes with it's criteria full keyword or partial of
keyword(widecard)
and press Cmdbutton ,any results(Records contains criterias) to be
displaied
in subform.
Any help/Suggestion would be appreciate
 
B

bijan

Thank you Arvin
the code was helpful ,I found out how to set up the controls ,and it is
working perfectly.
Bijan


Arvin Meyer said:
In VBA code you need to define the parameters because the Jet Expression
Service is not running. Something like (aircode):

Dim db as DAO.Database
Dim qdef as DAO.Querydef
Dim rst as DAO.Recordset

Set db = DBEngine.OpenDatabase("<<path to your MDB>>")
Set qdef = db.Querydefs("<<Your Select statement>>")
qdef.Parameters![txt2] = [Forms]![DIC]![txt2]

Set rst = qdef.Recordset
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

bijan said:
Hi Arvin,
Thank you for suggestion, But I wonder how do that! I have put
Like [Forms]![DIC]![txt2] &"*" in Record source of subform (criteria of
dic.name)
It worked but,just when I run the form query ask me the parametr value.
I prefer write a VBA code in on_click a commandbutton to obtain
criterias
from my textboxes and show records in my subform.
Please inform me where did I go wrong?
Thanks in advance
Arvin Meyer said:
You can write code using the BuildCriteria method, or much simpler, just
use
the form references in the query criteria, like:

[Forms]![frmFormName]![txtBoxName]

You can either type them in or right-click in the query's criteria box
and
choose Build.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

Hi all,
I have a form with four text box , one Cmdbutton and one subform
related
to
my table within four text feilds. What I need to do is: If user fill
each/all
text boxes with it's criteria full keyword or partial of
keyword(widecard)
and press Cmdbutton ,any results(Records contains criterias) to be
displaied
in subform.
Any help/Suggestion would be appreciate
 

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