473,386 Members | 1,763 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,386 software developers and data experts.

Selecting only one active record from multiple records

Hello all,

I do not know if this question is regarding table design, queries, or
programming. Below, I have given a table design using Access 2003.
Fields 'Product' and 'Color' are primary keys and 'Active'
is a Boolean data type. What I am trying to accomplish is having only
one record selected active out of the 'Product' field for each
type. If possible, have the user be able to do this task while viewing
the data within a continuous form.
Product Color Active
-----------------------------------------------
Shirt Blue
Shirt Yellow
Shirt Green True
Shirt Red
Shirt Black
Shirt Pink
Shirt White
Pants Blue
Pants Black True
Pants White
....

Thoughts or ideas?

TIA

M.L. Abram

Feb 9 '06 #1
3 2874
M.L. Abram wrote:
Hello all,

I do not know if this question is regarding table design, queries, or
programming. Below, I have given a table design using Access 2003.
Fields 'Product' and 'Color' are primary keys and 'Active'
is a Boolean data type. What I am trying to accomplish is having only
one record selected active out of the 'Product' field for each
type. If possible, have the user be able to do this task while viewing
the data within a continuous form.
Product Color Active
-----------------------------------------------
Shirt Blue
Shirt Yellow
Shirt Green True
Shirt Red
Shirt Black
Shirt Pink
Shirt White
Pants Blue
Pants Black True
Pants White
...

Thoughts or ideas?

TIA

M.L. Abram

Well, you could create a form with your three fields. Save it to
something, perhaps Subform

Then I'd create an unbound form. Call it MainForm.

I would drop in the form Subform into the form MainForm.

At the top would be three combos. Product, Color, Active. Product
combo would select distinct product from the table and union with an All
record. Color would select distinct colors for a product and union with
all colors for the product selected in the combo for Products. Then I'd
set another combo to -1;Yes/0;No/1;All for active. In the Afterupdate
event for each combo I'd call a routine to filter records.
The routine might look something like this aircode
sub setfilter
Dim strF As String
If Me.ComboProduct <> "ALL" then
strF = "ProductID = " & Me.ComboProduct & " And "
Endif
If Me.ComboColor <> "ALL" then
strF = strf & "ColorID = " & Me.ComboColor & " And "
Endif
If Me.ComboActive <> 1 then
strF = strf & "Active = " & Me.ComboActive & " And "
Endif
If strF > "" Then strF = Left(strF,len(strF)-5) 'remove And
Forms!MainForm!Subform.form.filter = strF
Forms!MainForm!Subform.form.filteron = true
end sub

This really doesn't answer your question but with some tweaking it will
get you started.
Feb 9 '06 #2
"M.L. Abram" <mi***********@gmail.com> wrote in
news:11**********************@o13g2000cwo.googlegr oups.com:
Hello all,

I do not know if this question is regarding table design,
queries, or programming. Below, I have given a table design
using Access 2003. Fields 'Product' and 'Color' are primary
keys and 'Active' is a Boolean data type. What I am trying to
accomplish is having only one record selected active out of
the 'Product' field for each type. If possible, have the user
be able to do this task while viewing the data within a
continuous form.
Product Color Active
-----------------------------------------------
Shirt Blue
Shirt Yellow
Shirt Green True
Shirt Red
Shirt Black
Shirt Pink
Shirt White
Pants Blue
Pants Black True
Pants White
...

Thoughts or ideas?

TIA

M.L. Abram


To rephrase your question, "How do I reset Active on the other
colors of the same product when I set active on one color of a
product (if that's not what you are asking, please resubmit the
question so we can guess again).

In the active.AfterUpdate event, run a query that sets active =
false WHERE product = 'shirt' and color <> 'green' Create the
query to use the form control values instead of the literal
values..

--
Bob Quintal

PA is y I've altered my email address.
Feb 9 '06 #3
Thank you for rephrasing the question. This is exactly what I am
attempting to do. I was thinking that I would need an ADO connection
to the table to change the values. I will work with a query then.

Cheers!

M.L. Abram

Feb 11 '06 #4

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

Similar topics

4
by: webhigh | last post by:
Iım not sure if this a PHP question or an MySQL question but here it goes. I have a repeat region of a table called userid What Iım trying to accomplish is being able to edit the record and...
10
by: Mark | last post by:
I have a table about people containing 25 fields. The table contains the usual fields - first, last, address, city, state and zip. There is no primary key. These fields all have data with the...
0
by: allyn44 | last post by:
HI--I have 2 tables Cut: cut ID, HistNumb, Block, date: Cut Id is the primary key, the other 3 fileds are indexed to be unique Slides: Cutid SlideID, and various other fields: there can be...
1
by: Anderson | last post by:
Can you please help? I have an appointment table and employees have multiple records in this table simple because their contracts change. The table has fields change date and reason for change...
22
by: RayPower | last post by:
I'm having problem with using DAO recordset to append record into a table and subsequent code to update other tables in a transaction. The MDB is Access 2000 with the latest service pack of JET 4....
4
dima69
by: dima69 | last post by:
Is it possible to select multiple records on datasheet via code ? Using SelTop and SelHeight properties dosn't give the same result as selecting the records manually, since record selectors remain...
8
by: salad | last post by:
I was wondering how you handle active/inactive elements in a combo box. Let's say you have a combo box to select an employee. Joe Blow has been selected for many record however Joe has left the...
7
by: john | last post by:
In my form I have a master table and a details table linked 1xM. I can search through the whole parent table but I also like to be able to search through the child table fields to find parent...
13
by: angi35 | last post by:
Hi - working in Access 2000... my goal is to combine fields from two tables in a query: Table 1 has ItemNumber and ItemDescription. There's only one record per ItemNumber. Table 2 has ItemAlias....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
jinu1996
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...

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.