I am creating a contact database and I would like the user to create
his own groups of contacts based on criterias, thefore I would like to
let him pick the fields and criteria for a particular group. I don't
wanna a form full of fields that ask the user for arguments. Instead a
subform with a combobox where the user picks the [field], the
[operator], and the [arguement]
So I would have two tables groups and GroupCriteria for instance:
group field operator criteria
_______________ _______________ ______
Accounts city = brooklyn
Accounts status < active
I then would live to each record to supply the query with these
arguements. Is the wrong way to go about it? How can I create my own
arguement. I see examples on how to pass but how do I create it using
code? 5 2938
this is the function that I am thinking might do it:
Function getsource(group )
End Function
Dim rec As DAO.Recordset
Dim db As DAO.Database
Set db = CurrentDb()
Dim sql As String
Dim qdf As QueryDef
Dim strsql As String
Dim fieldn As String
Dim oper As String
Dim crit As String
Dim surplus As String
Set rec = db.OpenRecordse t("select * from tblGroupCriteri a where
groupid = " & group)
strQueryName = "qryTemp"
If ((rec.BOF) And (Not rec.EOF)) Then
strsql = "SELECT * from tblIndividuals"
Set qdf = db.CreateQueryD ef(strQueryName , strsql)
Exit Function
End If
strsql = "SELECT * from tblIndividuals where "
With rec
If Not .EOF Then
fieldn = !FieldName
oper = !Operator
crit = !Criteria
End If
surplus = fieldn & " " & oper & " " & crit & "and"
strsql = strsql & surplus
Do While Not .EOF
fieldn = !FieldName
oper = !Operator
crit = !Criteria
surplus = "and" & fieldn & " " & oper & " " & crit
strsql = strsql & surplus
Loop
End With
End Function
Kaspa wrote:
I am creating a contact database and I would like the user to create
his own groups of contacts based on criterias, thefore I would like to
let him pick the fields and criteria for a particular group. I don't
wanna a form full of fields that ask the user for arguments. Instead a
subform with a combobox where the user picks the [field], the
[operator], and the [arguement]
So I would have two tables groups and GroupCriteria for instance:
group field operator criteria
_______________ _______________ ______
Accounts city = brooklyn
Accounts status < active
I then would live to each record to supply the query with these
arguements. Is the wrong way to go about it? How can I create my own
arguement. I see examples on how to pass but how do I create it using
code?
off the top of my head (do I ever do anything any other way?), You
could open a recordset of all the records for a specific group, e.g.
SELECT Group, Field, Operator, Criteria
FROM GroupCriteria
WHERE group = <point at a form here?>
Then you could simply walk through the recordset...
do until rs.EOF
strFilter = strFilter & " AND " &
rs.Fields("Fiel d") & rs.Fields("Oper ator") & fDelimiter(fiel dType)
& rs.Fields("Valu e") & fDelimiter(fiel dType)
rs.MoveNext
Loop
or you could save these as different queries (just not let the user see
them)...
Kaspa,
I was thinking along the same lines (doesn't make it right, mind you).
One thing I thought about, though, is delimiters - stuff that the QBE
grid puts in there for you. (so maybe if you build querydefs on the
fly, you may not need them). you might want to check field types so
that you're sure you include delimiters for literal values, like dates
(#), strings ('), etc.
I guess if you wait for the other folks here to sleep and have coffee,
you'll get more answers.
but that's my two cents... at a discount.
Pieter
thank you for that, I was not think about it. pi********@hotm ail.com wrote:
Kaspa,
I was thinking along the same lines (doesn't make it right, mind you).
One thing I thought about, though, is delimiters - stuff that the QBE
grid puts in there for you. (so maybe if you build querydefs on the
fly, you may not need them). you might want to check field types so
that you're sure you include delimiters for literal values, like dates
(#), strings ('), etc.
I guess if you wait for the other folks here to sleep and have coffee,
you'll get more answers.
but that's my two cents... at a discount.
Pieter
Anybody else has any input? pi********@hotm ail.com wrote:
Kaspa wrote:
I am creating a contact database and I would like the user to create
his own groups of contacts based on criterias, thefore I would like to
let him pick the fields and criteria for a particular group. I don't
wanna a form full of fields that ask the user for arguments. Instead a
subform with a combobox where the user picks the [field], the
[operator], and the [arguement]
So I would have two tables groups and GroupCriteria for instance:
group field operator criteria
_______________ _______________ ______
Accounts city = brooklyn
Accounts status < active
I then would live to each record to supply the query with these
arguements. Is the wrong way to go about it? How can I create my own
arguement. I see examples on how to pass but how do I create it using
code?
off the top of my head (do I ever do anything any other way?), You
could open a recordset of all the records for a specific group, e.g.
SELECT Group, Field, Operator, Criteria
FROM GroupCriteria
WHERE group = <point at a form here?>
Then you could simply walk through the recordset...
do until rs.EOF
strFilter = strFilter & " AND " &
rs.Fields("Fiel d") & rs.Fields("Oper ator") & fDelimiter(fiel dType)
& rs.Fields("Valu e") & fDelimiter(fiel dType)
rs.MoveNext
Loop
or you could save these as different queries (just not let the user see
them)...
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Iain Miller |
last post by:
Now this shouldn't be hard but I've been struggling on the best way as to
how to do this one for a day or 3 so I thought I'd ask the assembled
company.....
I'm writing an application that tracks a group of Sales people, the
customers they deal with and the business they transact with them.
I've got my head around all the tables & some of the basic Query structures
OK and am beginning to delve into creating the forms I need to be able...
|
by: Jeremy Weiss |
last post by:
Thanks to much help from everyone in my previous thread, I've made it a
pretty fair ways into my billing/invoicing db.
I'm now needing a way to cycle through all the records in a table and create
invoice records for them in another table, but I have no idea where to
begin. Here's the relevant tables:
==============
Table: Customer_tbl
|
by: Darleen |
last post by:
I am seeking conceptual here on how to get started with a "3D Matrix"
in Access. We run a training center which holds multiple classes in
multiple cities at multiple times. So I need to create a matrix with
3 "axis". The 3 axes are:
City Location
Week of Class (in 14 week increments that repeat)
Name of Class
The end goal is to be able to have a form that shows these classes in
|
by: Trent |
last post by:
I am in the design phase of a new database and am having a devil of a
time with a subform.
I have three tables that relate to problem - Suppliers tbl, Customers
tbl and a SuppliersCustomers tbl. The intent is to have the user enter
in spend information by customer with each supplier. Sounds simple
enough right?
The common fields in each table are as follows:
|
by: sunrisewinesalon |
last post by:
New here--I posted this to another group called 'ms access problems,'
but it only had one member...
Access says you can choose fields from more than one table or query to
create a form--but can you use fields from one of each?
Thanks
| |
by: rreitsma |
last post by:
I want to create a form that will allow the user to select from a list of
available reports and based on a filter limit the records displayed in the
report. I have figured out how to access the reports collection to populate
a list box containing the report names. The filter I currently have lists
some key fields that I think the user may want to filter on. A WHERE string
is constructed based on the feilds that the user inputs values into....
|
by: DeanL |
last post by:
Hi Guys,
I need some help creating a query that is going to take between 1 and
10 parameters. The parameters are entered on a form into text boxes
that may have data or be empty. Is there a way to create a single
query that will take parameters if they are present in the text boxes
and not take parameters if the text box is empty?
The ten fields will need to be searched using "Like" so that the user
can search on part of a text...
|
by: FrozenDude |
last post by:
Hello and thanks in advance.
I've read through the threads but can't seem to make this work.
I have a form with a combo box (named DateCode) that provides a table
column name and a subform that contains two columns. The subform is
based on a pre-established SQL query (query returns two fields).
I want to use the DateCode selection to add a column to the select
portion of the SQL query, or replace it altogether, with a query that
|
by: MikeMikerson |
last post by:
Hello,
I am need to create a subform (no problem) of a form based query (a problem).
I need a form that will prompt the user to enter in a name, and the form will then display a query of the persons transactions.
The ideal situation would be that the executed query would remain as part of the record because there will be many of these "searches" stored within this form.
I have:
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |