473,587 Members | 2,588 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_Descriptio n_ID (key - 1:M to tblSalesDetails )
Active_Status (boolean)

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

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

Query:
SELECT tblItemDetails. Item_Descriptio n_ID,
tblItemDetails. Active_Status, tblSalesMaster. Company_Locatio n,
Max(tblSalesMas ter.Sale_Date) AS MaxOfSale_Date
FROM tblSalesMaster INNER JOIN (tblItemDetails INNER JOIN
tblSalesDetails ON tblItemDetails. Item_Descriptio n_ID =
tblSalesDetails .Menu_Descripti on_ID) ON tblSalesMaster. Sales_ID =
tblSalesDetails .Sales_ID
GROUP BY ... etc ...
Sep 27 '08 #1
6 2225
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_Descriptio n_ID,
tblItemDetails. Active_Status,
tblSalesMaster. Company_Locatio n,
tblSalesMaster. Sale_Date
FROM tblSalesMaster
INNER JOIN (tblItemDetails
INNER JOIN tblSalesDetails
ON tblItemDetails. Item_Descriptio n_ID = tblSalesDetails .Menu_Descripti on_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_Descriptio n_ID,
tblItemDetails. Active_Status,
tblSalesMaster. Company_Locatio n,
tblSalesMaster. Sale_Date
FROM tblSalesMaster
INNER JOIN (tblItemDetails
INNER JOIN tblSalesDetails
ON tblItemDetails. Item_Descriptio n_ID = tblSalesDetails .Menu_Descripti on_ID)
ON tblSalesMaster. Sales_ID = tblSalesDetails .Sales_ID
WHERE tblSalesMaster. Sale_Date =
(SELECT Max(Dupe.Sale_D ate) 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.c omwrote in message
news:60******** *************** ***********@59g 2000hsb.googleg roups.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_Descriptio n_ID (key - 1:M to tblSalesDetails )
Active_Status (boolean)

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

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

Query:
SELECT tblItemDetails. Item_Descriptio n_ID,
tblItemDetails. Active_Status, tblSalesMaster. Company_Locatio n,
Max(tblSalesMas ter.Sale_Date) AS MaxOfSale_Date
FROM tblSalesMaster INNER JOIN (tblItemDetails INNER JOIN
tblSalesDetails ON tblItemDetails. Item_Descriptio n_ID =
tblSalesDetails .Menu_Descripti on_ID) ON tblSalesMaster. Sales_ID =
tblSalesDetails .Sales_ID
GROUP BY ... etc ...
Sep 27 '08 #2
On Sep 27, 12:01*am, Kelii <kel...@yahoo.c omwrote:
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_Descriptio n_ID (key - 1:M to tblSalesDetails )
Active_Status (boolean)

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

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

Query:
SELECT tblItemDetails. Item_Descriptio n_ID,
tblItemDetails. Active_Status, tblSalesMaster. Company_Locatio n,
Max(tblSalesMas ter.Sale_Date) AS MaxOfSale_Date
FROM tblSalesMaster INNER JOIN (tblItemDetails INNER JOIN
tblSalesDetails ON tblItemDetails. Item_Descriptio n_ID =
tblSalesDetails .Menu_Descripti on_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.c omwrote:
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.c omwrote in
news:60df8351-71f2-4f22-a218-42ff2590f1d5@
59g2000hsb.goog legroups.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_Descriptio n_ID (key - 1:M to tblSalesDetails )
Active_Status (boolean)

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

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

Query:
SELECT tblItemDetails. Item_Descriptio n_ID,
tblItemDetails. Active_Status, tblSalesMaster. Company_Locatio n,
Max(tblSalesMas ter.Sale_Date) AS MaxOfSale_Date
FROM tblSalesMaster INNER JOIN (tblItemDetails INNER JOIN
tblSalesDetails ON tblItemDetails. Item_Descriptio n_ID =
tblSalesDetails .Menu_Descripti on_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
2046
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(); if (isset($HTTP_SESSION_VARS))
1
6276
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 ";'. J'ai créé un script qui upload le fichier texte sur le serveur et qui lit le contenu de chaque ligne, sépare chaque champ, puis stocke les données...
6
5366
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 d'un favoris dans un msgbox? Raymond H. logicipc@sympatico.ca
2
4910
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 l'utilizzo allo scadere di un dato periodo (ad esempio 30 giorni) o come implementare l'algoritmo per il controllo della chiave di sblocco. Grazie...
5
1966
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 déposé un code permettant visiblement de passer un script en argument tout en signant son passage (rory). Je voulais savoir quel était la meilleure...
1
3361
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 sulla datagrid stessa. - nel namespace ho dichiarato un riferimento al form in questo modo: private static Form1 f; - nel form load istanzo e...
15
1877
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 unos tipejos me están echando el negocio al suelo pues hablan pestes de .NET y le dicen al director de sistemas de la compañía que Linux y PHP son...
3
2887
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 dbgrid pero tiene otras peculiaridades ahi que facilitan muchas tareas. Si alguno ha usado este control talvez me podria ayudar. El asunto esta asi,...
1
1244
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 connection (3) and found it had no notion about using a non-default map. After convincing myself that this must be a simple oversight in asynchat, I...
1
2638
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 text</b<textarea>bar and so forth...</textarea> here my final content.</div> The output should be:
0
7843
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...
0
8340
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7967
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...
0
8220
tracyyun
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...
0
3840
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3875
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2353
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
1
1452
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1185
bsmnconsultancy
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...

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.