Solved Finding specific Record index (1 Viewer)

Rashid

Member
Local time
Today, 03:22
Joined
Sep 6, 2019
Messages
30
RecID(autoNo)StuIDStuNameData
11aDr
22bCr
31aCr
41aCr
52bDr
In a Continuous Form

I Need when I select recid4; a textbox (unbound)

Show me “This is 3rd Transaction of this student”

So what code will be applied in unbound tex
 

amorosik

Member
Local time
Today, 12:22
Joined
Apr 18, 2020
Messages
397
For example, on Form_Current event

msgbox("This is " & dlookup("count(*)","table_name","StudID=" & me!StudID & " and RecID<=" & me!RecID) & " transaction bla bla bla...")
 
Last edited:

bastanu

AWF VIP
Local time
Today, 03:22
Joined
Apr 13, 2010
Messages
1,402
I think you need to use a ranking query grouped by student and sorted by the RecID to get what you need:

Cheers,
 

Rashid

Member
Local time
Today, 03:22
Joined
Sep 6, 2019
Messages
30
For example, on Form_Current event

msgbox("This is " & dlookup("count(*)","table_name","StudID=" & me!StudID & " and RecID<=" & me!RecID) & " transaction bla bla bla...")
Not working ,,,,
 

bastanu

AWF VIP
Local time
Today, 03:22
Joined
Apr 13, 2010
Messages
1,402
Because you want an index or rank, not a total count; have you tried to use my link?
 

Rashid

Member
Local time
Today, 03:22
Joined
Sep 6, 2019
Messages
30
Not working ,,,,
After googling i have got the solution and That is:- Creat a query add a new column RecNo with this Code: RecNo: DCount("transid","feetable query","transid<" & [transid] & "AND STUDENTID=" & [STUDENTID])+1 and in the form in which i need the value place a unbound textbox with the code: dlookup("Recno","QueyName","transid="&[transid]). It Is working great.No Body Give this solution in this forum.????
 

bastanu

AWF VIP
Local time
Today, 03:22
Joined
Apr 13, 2010
Messages
1,402
Because it is similar to the approach used in Allen's link I provided you in post #3 (but potentially slower with large record sets because you are using dCount instead of Count in a totals subquery). but you ignored it....
Anyway looks like you learned something new and maybe next time a similar question comes in maybe you can jump in to help.
Cheers,
 

amorosik

Member
Local time
Today, 12:22
Joined
Apr 18, 2020
Messages
397
No Body Give this solution in this forum.????

Maybe because it's not the simplest solution
Could you please tell me what was wrong with the recommended code?

dlookup("count(*)","table_name","StudID=" & me!StudID & " and RecID<=" & me!RecID)


1670058344061.png
 

Users who are viewing this thread

Top Bottom