In the set field step, there are two options. One which you have found it to define the target field. The other is Calculated result, this is where you would enter your "1".
Thanks Mark, that works a treat.
It was the quotes that threw me as it is a numerical field I wanted to reset to 1.
Unfortunately it hasn't solved my underlying problem of an overal record count still including deleted records.
Any advice on this aspect?
For a count of current records, you could use the Get (current record count) function.
Describe what you mean by "overall record count". The count of records shown in the status area should update correctly when you delete one or more records, so I must assume that you are looking at some other record count or expecting that record count to reflect the number of records in a different table than that specified for that layout in the "show records from" drop down in Layout Setup.
Phil & Mark,
Tks again for your input.
My problem is that each database table has a 'Record No.' field which increments by 1 each time a record is added.
However, when a record is deleted, this field still counts it. e.g. The forst record isn't a problem, but if, when entering a second record, it is deleted for whatever reason, the next record will be #3 even though there are only 2 records in the database.
That is the problem I am trying to overcome, can either of you help, or is this a characteristic of FMP that I'm gonna have to live with?
Why is it a problem?
Gaps in the number series usually aren't something that causes any problem. Which value is entered next in an auto-entered serial number is controlled by a next serial value property that can be reset by script, but I don't recommend that you do this unless you have a very good reason to do so. (And this only works if the record with the largest ID number is deleted.)
There are a number of ways to display lists of numbers with gap free sequence numbers (display purposes only) and also ways to count the number of records in your table or found set that do not require a perfect numbering series to do so.
There is a difference between the count of records and the serial number. As Phil said, a gap in serial number is not an issue and can cause problems if you try to override it. It is better to have a separate field for record count, which you can get using a calculation for display purposes.
Any relationships should be based on the autoentered serial number though.
Tks for that, a valid point indeed.
I guess that I'll have to approach this project from a different angle.
I have yet to discover a function, or script, which will provide an accurate count of records in a table.
Your post came in just as I was responding to Phil.
As you can probably tell, my experience with Db programming is extremely limited, and of course, whatever Db applications I've played with in the past differ vastly in available functions and scripting syntax. It makes the learning curve so much steeper, but thanks to the likes of you, Phil and numerous others, I am getting there, albeit painfully slowly.
Thanks again to all you guys (and gals) who give up theeir valuable time to assist people like me.
Look up the get function in FileMaker help. This is a swiss army knife kind of function that can be used to tell you many different things about your database depending on which parameter you specify.
To count the records in the current layout's found set: Get ( FoundCount )
To count the total records in the current layout's table: get ( TotalRecords )
To count the number of records in a related table that are related to the current record in your layout: Count ( RelatedTable::NeveryBlankField ). You can also use a "count of" summry field from the related table to get the same count.
To count the total records in a different table a) use a script to change to a layout based on that table and use Get ( totalRecords ) to count them. or b) set up a relationship based on X instead of = and use one of the two methods for counting related recors. (The cartesian join operater, X, sets up a relationship that matches to all records in the related table.)
I think I'm relying too much on the "FMP Design & Scripting for Dummies".
I may be a 'Dummy' but I'm not finding the book to be much help.
I find the official documentation to be so awesomely vast and so difficult to find specific information.
Your help, along with everyone else on the forum, is invaluable, and it's the only thing that keeps me plugging away at this marvellous, yet totally frustrating, piece of software.
If you go to Help and enter "get" then click List Topics, then Click Display, you should be able to get a nice list of all permutations of the Get function. You can then click one to see the details on that specific combination of Get and parameter. I find myself checking this list often when I hit a challenge for which an immediate solution does not instantly come to mind.
Yes, Filemaker can be like that. It is marvelous in the things it can do, but sometimes frustrating in figuring out how to get it to do it.
This forum, Phil is one of the best, has saved me what little hair I have left many times.
I have created a field on my layout using 'Get (TotalRecordCount)' to display the total number of records in the associated table, and it works as expected.
Except however, when I step through the records using button script 'Go to Record/Request/Page ', the field I created is incremented, or decremented as I step forwards, or backwards, through the records.
Something, somewhere doesn't add up?