How about this (in a calculation field or web viewer with data url or merge variable)
Let ( [
fc = Get (FoundCount);
tc = Get (TotalRecordCount);
"Record No: " & Get (RecordNumber) & " of " & fc & Case (fc ≠ tc; "; " & tc & " total")
This will display "Record No: X of X" with the addition of "; XX total" if there are other records not in the current found set.
Hope this helps
AM I correct in assuming that I have to create a field in my table and then create the above as a calculation for that field? If so do i have to do this for every table for each of my layouts?
There are a couple posts on my blog that take you through this step-by-step.
This one uses a calculation field, but I like Matt's calculation better than the one I use:
This one uses a Web viewer, and means you don't have to create a field in each table:
FileMaker Database Superhero,
Spafford Data Solutions
Tel: 613 838 9956
FileMaker User Group in Ottawa:
If you are using a script to change records, you can use a set variable
statement and put the text string into a global variable and put a merge
variable at the correct location on the screen.
If there isn't a script you can add an OnRecordload script trigger and
create a script to set the variable.
Hope this helps
You could create a field in every table if you so wished. You could copy / paste it between tables as it doesn't reference any fields.
Or you can use a web viewer to display it and so avoid any fields at all (that's what I do). Using this method makes it easy to adjust to the context of your layout too, so you can have "Job No: X of X" or "Contact No: X of X". Paul's link shows you how to use a web viewer to display a data url (by the way I'm a big fan Paul, keep up the good work!). I use a slightly different set of custom functions that Matt Petrowsky wrote (can't find the link now, but let me know if you're interested and I'll keep digging) that allows me to specify CSS seperately, so I can style the html to fit the layout.
Or you could define a merge variable to display the information, but this is probably not worth the effort, since you'd need to trigger it to change with every change in the found set...
Actually, you can use a merge variable without a script. I prefer doing it this way over the webviewer technique because it gives me FileMaker-native control of the text formatting. You create two merge variable text objects: <<$calculation>> and <<$recordPosition>>. <<$recordPosition>> must be above <<$calculation>> in the layout object layering for this to work correctly. (This doesn't mean it has to be directly on top of <<$calculation>>, just further forward.) On the <<$calculation>> object, you add a conditional format based on this calculation:
Let ( [
$recordPosition = /* record position calculation of your choice */;
$calculation = ""
This will set the merge variable for you without the need for a script, and you have full control over how it looks without having to know CSS. As an added bonus, it works correctly when you have multiple windows open because it uses $local rather than $$global variables — the scripted version would have to use $$global variables, and so would have to show one record position for all windows, even if two windows are on different records.
If you choose to go with a Merge Variable, you can use a Conditional Formatting ( couple posts here that explain it briefly )trick to make it refresh with every redraw (that way it's always correct). I either use the Web Viewer, or a Merge Variable. So no fields...just depends on the situation if I use the Web Viewer or Merge Variable.
Edit: Great tip Jeremy. We must have been typing at the same time. hehe
Message was edited by: jormond
Very nice, thanks for the tip. Didn't realise you could local variables in this way.
Yeah it's a cool tip. I came across it totally by accident one day when I was testing something else. Another nice thing about it, it doesn't clash with variables in scripts. If a script sets the $variable with the same name, the variable assumes the value from the script until the end of the script. Once the script is done, the $variable reverts back to what it was set at before the script.
Thank you for that. I have tried as you have explained but my knowledge is limited.
Are you able to provide a sample file for me?