Solved How to hide records if a revision reaches a certain amount (1 Viewer)

Sodslaw

Registered User.
Local time
Yesterday, 19:14
Joined
Jun 7, 2017
Messages
81
Hi I wonder if anyone can help..

i have this table...
TblQuote
QuoteIDQuoteNoQuoteVerHideQuote
210721071No
210921072No
211121073No


when the user creates a new version i would like to know how to calculate and hide old records for a given QuoteNo (all except from the previous version.)
ie as version 3 is created hide version 1 (HideQuote=yes) so that only 2 records exists for each quote, the new and previous record (ver2 &Ver3) and if a 4th version is created hide ver2 and so on

calculating the the revision numbers was easy Me.QuoteVer = DMax("QuoteVer", "[TblQuote]", Me.QuoteNo) but hiding them..... ohhhhh
could i use the dmax?

i know there are good VBAers in our community, but this one for me is well over my head skill or knowledge of VBA (have been trying for several days on and off)

appreciate any comments, thanks guys.
 
Last edited:

Ranman256

Well-known member
Local time
Yesterday, 22:14
Joined
Apr 9, 2015
Messages
4,337
in the query hide the field , replace the field value with a blank:
MyField: IIf([field]>1, "", [field])

or
just filter out the record in the query using WHERE.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 10:14
Joined
May 7, 2009
Messages
19,230
you can also use Query to hide them:

SELECT tblQuote.*
FROM tblQuote
Where QuoteVer IN
(SELECT TOP 2 QuoteVer FROM tblQuote AS T WHERE T.QuoteNo = tblQuote.QuoteNo Order By QuoteVer Desc)
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 03:14
Joined
Jul 9, 2003
Messages
16,280
I think you need two queries. The first query would hide all of the records. The second query selects the top 2 records and unhides them...
 

Sodslaw

Registered User.
Local time
Yesterday, 19:14
Joined
Jun 7, 2017
Messages
81
Brilliant thanks for the guidance i will i am sure be able to to sort this (TOP 2 i didnt even know there was such a thing) and thanks for the refernce pages its making sence to me now... thanks again guys!
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 03:14
Joined
Jul 9, 2003
Messages
16,280
I just did a quick check. You can't (well I can't) make a Top selection and update the records at the same time. You'll need another query that takes the results of the top query and updates that..

Code:
'Query1
SELECT TOP 2 [Order Details].OrderID, [Order Details].ProductID, [Order Details].UnitPrice, [Order Details].Quantity, [Order Details].Discount, [Order Details].flag
FROM [Order Details]
WHERE ((([Order Details].OrderID)=10684));

'Query2
UPDATE Query1 SET Query1.flag = True;
 

Gasman

Enthusiastic Amateur
Local time
Today, 03:14
Joined
Sep 21, 2011
Messages
14,260
Could you not just use a WHERE clause of VersionID >= Dmax(the versionID) - 1
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 10:14
Joined
May 7, 2009
Messages
19,230
see post #3, you do not need to update the table.
here is the result:
Query1 Query1

IDQuoteIDQuoteNoQuoteVerHideQuote
2​
2109​
2107​
2​
No​
3​
2111​
2107​
3​
No​
4​
2113​
2108​
1​
No​
 

Sodslaw

Registered User.
Local time
Yesterday, 19:14
Joined
Jun 7, 2017
Messages
81
Sorry i had to pop out for a bit but it seems to work well (testing over time will tell)
i used @arnelgp method with a requery and then using the find method to go back to the original record, after it was lost during the requery.
Code:
            me.QuoteID = QuoteIDtmp
            Me.Requery
            Me.QuoteID.SetFocus
            DoCmd.FindRecord QuoteIDtmp, , , , , acCurrent
thanks again guys you are all amazing!
 
Last edited:

Users who are viewing this thread

Top Bottom