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

Work around for 'un-editable' recordset which utilizes the maxaggregate function

Hello,

So I have a form which shows all items available for sale, when it was
last sold, where it was last sold, and whether it is active or
inactive.

I would like to be able to edit the active/inactive field (its a yes/
no or boolean type field); however, I am not able to make these edits
because of the max aggregate function used on the sale date.

My question is: does anyone have a work around to this issue?

Note: that I did look through help "When can I update data from a
query" and none of the scenarios seemed to match my situation.

So here's the full background:
tblItemDetails:
Item_Description_ID (key - 1:M to tblSalesDetails)
Active_Status (boolean)

tblSalesDetails:
Sales_ID (key - M:1 to tblSalesMaster)
Item_Description_ID (key - M:1 to tblItemDetails)
Count_Sold

tblSalesMaster:
Sales_ID (key - 1:M to tblSalesDetails)
Company_Location
Sale_Date

Query:
SELECT tblItemDetails.Item_Description_ID,
tblItemDetails.Active_Status, tblSalesMaster.Company_Location,
Max(tblSalesMaster.Sale_Date) AS MaxOfSale_Date
FROM tblSalesMaster INNER JOIN (tblItemDetails INNER JOIN
tblSalesDetails ON tblItemDetails.Item_Description_ID =
tblSalesDetails.Menu_Description_ID) ON tblSalesMaster.Sales_ID =
tblSalesDetails.Sales_ID
GROUP BY ... etc ...
Sep 27 '08 #1
6 2210
The GROUP BY clause guarantees a read-only result.

First, try it without the GROUP BY, and see if the results are editable:

SELECT tblItemDetails.Item_Description_ID,
tblItemDetails.Active_Status,
tblSalesMaster.Company_Location,
tblSalesMaster.Sale_Date
FROM tblSalesMaster
INNER JOIN (tblItemDetails
INNER JOIN tblSalesDetails
ON tblItemDetails.Item_Description_ID = tblSalesDetails.Menu_Description_ID)
ON tblSalesMaster.Sales_ID = tblSalesDetails.Sales_ID

If that't not editable, there's no point going further.

It is is, try adding a subquery to the WHERE clause.
Something along these lines:

SELECT tblItemDetails.Item_Description_ID,
tblItemDetails.Active_Status,
tblSalesMaster.Company_Location,
tblSalesMaster.Sale_Date
FROM tblSalesMaster
INNER JOIN (tblItemDetails
INNER JOIN tblSalesDetails
ON tblItemDetails.Item_Description_ID = tblSalesDetails.Menu_Description_ID)
ON tblSalesMaster.Sales_ID = tblSalesDetails.Sales_ID
WHERE tblSalesMaster.Sale_Date =
(SELECT Max(Dupe.Sale_Date) AS MaxOfSale_Date
FROM tblSalesMaster AS Dupe
WHERE Dupe.Sales_ID = tblSalseMaster.Sales_ID)

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Kelii" <ke****@yahoo.comwrote in message
news:60**********************************@59g2000h sb.googlegroups.com...
>
So I have a form which shows all items available for sale, when it was
last sold, where it was last sold, and whether it is active or
inactive.

I would like to be able to edit the active/inactive field (its a yes/
no or boolean type field); however, I am not able to make these edits
because of the max aggregate function used on the sale date.

My question is: does anyone have a work around to this issue?

Note: that I did look through help "When can I update data from a
query" and none of the scenarios seemed to match my situation.

So here's the full background:
tblItemDetails:
Item_Description_ID (key - 1:M to tblSalesDetails)
Active_Status (boolean)

tblSalesDetails:
Sales_ID (key - M:1 to tblSalesMaster)
Item_Description_ID (key - M:1 to tblItemDetails)
Count_Sold

tblSalesMaster:
Sales_ID (key - 1:M to tblSalesDetails)
Company_Location
Sale_Date

Query:
SELECT tblItemDetails.Item_Description_ID,
tblItemDetails.Active_Status, tblSalesMaster.Company_Location,
Max(tblSalesMaster.Sale_Date) AS MaxOfSale_Date
FROM tblSalesMaster INNER JOIN (tblItemDetails INNER JOIN
tblSalesDetails ON tblItemDetails.Item_Description_ID =
tblSalesDetails.Menu_Description_ID) ON tblSalesMaster.Sales_ID =
tblSalesDetails.Sales_ID
GROUP BY ... etc ...
Sep 27 '08 #2
On Sep 27, 12:01*am, Kelii <kel...@yahoo.comwrote:
Hello,

So I have a form which shows all items available for sale, when it was
last sold, where it was last sold, and whether it is active or
inactive.

I would like to be able to edit the active/inactive field (its a yes/
no or boolean type field); however, I am not able to make these edits
because of the max aggregate function used on the sale date.

My question is: does anyone have a work around to this issue?

Note: that I did look through help "When can I update data from a
query" and none of the scenarios seemed to match my situation.

So here's the full background:
tblItemDetails:
Item_Description_ID (key - 1:M to tblSalesDetails)
Active_Status (boolean)

tblSalesDetails:
Sales_ID (key - M:1 to tblSalesMaster)
Item_Description_ID (key - M:1 to tblItemDetails)
Count_Sold

tblSalesMaster:
Sales_ID (key - 1:M to tblSalesDetails)
Company_Location
Sale_Date

Query:
SELECT tblItemDetails.Item_Description_ID,
tblItemDetails.Active_Status, tblSalesMaster.Company_Location,
Max(tblSalesMaster.Sale_Date) AS MaxOfSale_Date
FROM tblSalesMaster INNER JOIN (tblItemDetails INNER JOIN
tblSalesDetails ON tblItemDetails.Item_Description_ID =
tblSalesDetails.Menu_Description_ID) ON tblSalesMaster.Sales_ID =
tblSalesDetails.Sales_ID
GROUP BY ... etc ...
I've worked around this problem by
1) unbinding the field from the control on the form
2) use a dlookup() in the on Current Event of the form to retrieve the
value
3) update the table using a SQL update query triggered in the
AfterUpdate event of the control. (yes it fires on unbound controls)
4) repeating the Dlookup()

Sep 27 '08 #3
I'll just modify the above comments with one idea that popped into my
head after thinking about this all night.

I could create a temporary table (again a slow process over a network)
that stores the item, sale date, and sale location. Then rebuild the
query based on the permanent items table and the temporary table.

Although I haven't tested this idea, I think it would be considerably
faster.

My only hesitation here is that I don't like building temporary
tables. To me, it feels like I'm creating clutter, ableit temporary,
and it leaves open the possibility for inadequate error handling to
remove the temp table when the form is closed.

Anyhow, thoughts are welcome.

kelii
Sep 28 '08 #4
On Sep 27, 4:55*pm, Kelii <kel...@yahoo.comwrote:
Allen,

P.S. rquintal - thank you as well for your suggestion. In my
experience, unbinding a check box in a continuous form results in a
series of check boxes that do not work properly; namely, if you check
the box for one record, all the records become checked and vice versa.
Would be interested if you understand differently or if I
misinterpreted your post.
You are absolutely right. Unbound controls on continuous forms show
the value calculated for the current row on all rows. I should have
determined that the form was Continuous by the phrase 'shows all items
', as opposed to my interpretation as a form with an all rows
recordset.

However, sometimes leaving the control bound but doing the update via
a query, then undoing the change in the control's before update might
work.
Sep 28 '08 #5
Allen,

Thanks for your post. I didn't realize a list of reserved words
existed. I've bookmarked and will refer to this in the future. It
would sure be a huge bummer if I had to go back and revise my
queries / code / forms etc... for the whole Class thing.

I am now building a separate form with highly similar functionality to
the form discussed in this post. I'm going to try the temp table
method and see how it works.

rquintal,

You know I should probably have mentioned the continuous form aspect
of the problem. Unlike others, I tend to leave important facts out of
my posts ... apologies.

Roger,

I'm up for trying any suggestion and will give your's a shot.

Thanks again,

kelii
Sep 28 '08 #6
Kelii <ke****@yahoo.comwrote in
news:60df8351-71f2-4f22-a218-42ff2590f1d5@
59g2000hsb.googlegroups.com
:
Hello,

So I have a form which shows all items available for sale, when it
was last sold, where it was last sold, and whether it is active or
inactive.

I would like to be able to edit the active/inactive field (its a
yes/ no or boolean type field); however, I am not able to make
these edits because of the max aggregate function used on the sale
date.

My question is: does anyone have a work around to this issue?

Note: that I did look through help "When can I update data from a
query" and none of the scenarios seemed to match my situation.

So here's the full background:
tblItemDetails:
Item_Description_ID (key - 1:M to tblSalesDetails)
Active_Status (boolean)

tblSalesDetails:
Sales_ID (key - M:1 to tblSalesMaster)
Item_Description_ID (key - M:1 to tblItemDetails)
Count_Sold

tblSalesMaster:
Sales_ID (key - 1:M to tblSalesDetails)
Company_Location
Sale_Date

Query:
SELECT tblItemDetails.Item_Description_ID,
tblItemDetails.Active_Status, tblSalesMaster.Company_Location,
Max(tblSalesMaster.Sale_Date) AS MaxOfSale_Date
FROM tblSalesMaster INNER JOIN (tblItemDetails INNER JOIN
tblSalesDetails ON tblItemDetails.Item_Description_ID =
tblSalesDetails.Menu_Description_ID) ON tblSalesMaster.Sales_ID =
tblSalesDetails.Sales_ID
GROUP BY ... etc ...
I've worked around this problem by
1) unbinding the field from the control on the form
2) use a dlookup() in the on Current Event of the form to retrieve
the value
3) update the table using a SQL update query triggered in the
AfterUpdate event of the control. (yes it fires on unbound controls)
4) repeating the Dlookup()

--
Bob Quintal

PA is y I've altered my email address.
** Posted from http://www.teranews.com **
Sep 30 '08 #7

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

Similar topics

6
by: NotGiven | last post by:
session_start(); if (isset($HTTP_SESSION_VARS))&&($HTTP_SESSION_VARS != '') echo "hello"; It doesn't throw an error it just doesn't display anything However, this works: session_start();...
1
by: Agathe | last post by:
Bonjour, Je souhaite insérer dans une table MySQL des données provenant d'un fichier texte grâce à un script PHP. Mon fichier porte l'extension "txt" et les données sont séparées par des ";'. ...
6
by: Raymond H. | last post by:
Bonjour, Je n'arrive pas à savoir comment lire via vb4 l'adresse d'un favoris dans le dossier des favoris où Internet Explorer place ses favoris. Par exemple, comment fait-on pour afficher l'url...
2
by: Mauro | last post by:
Ciao a tutti! vorrei sapere se qualcuno potrebbe darmi qualche dritta (o se sa dove reperire un tutorial) su come realizzare un trial a tempo, da integrare ad un mio programma per impedirne...
5
by: Chris | last post by:
Bonjour, Plusieurs fichiers PHP d'un programme open source de compteur de visites viennent de se faire hacker sur mon serveur (hébergement mutualisé chez un fournisseur d'accès). Le hacker a...
1
by: Alex | last post by:
Ciao a tutti, sto sviluppando un applicazione windows, in breve all'interno dello stesso namespace ho un form con una datagrid e un thread che effettua dei controlli e "dovrebbe" caricare i dati...
15
by: Ciudad Tecnópolis | last post by:
Hola, primero que todo mil disculpas por postear una pregunta no relacionada al tema pero se que será muy útil para todos! Actualmente estoy presentando un desarrollo en .NET para una compañía y...
3
by: nano9 | last post by:
Hola gente quisiera que alguien me pudiera ayudar con un problemilla que tengo, resulta que estoy programando en ASP con C# y estoy usando un cadbgrid que se comporta parecido a un datagrid o...
1
by: Martin Maney | last post by:
Simple asyncore application where I wanted to use an explicit map (1) rather than the automagic default. Worked fine until I tried to use asynchat to handle an interactive status and control...
1
by: nubster21 | last post by:
I would like to split a string of HTML output into an array on textarea tags. Example: <div>Hello this is my content <textarea>foo</textareaand this is also content <b>some bold...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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: 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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.