I would need to see a bit more of your solution's schema to really offer useful ideas. Sounds like Go To Related Record is what you are looking for. Can you show us what tables, relationships, fields you are dealing with and on what table occurrences your starting and ending layouts are based?
Enter Find Mode
Set Field [ User First Name; Value: "==" & Get(accountname)]
Should find you just the records for the account name. I don't know what you mean by "and matching this first name with sample record first name in the layout".
Unless first names are unique, your relationship might match to records for more than one user.
If If this is a security issue, you should set up Record Level Acess Control in Manage Security.
But Go To Related Records can definitely be used from a layout based on users to show all related records on a layout based on Sample Info. But there are a number of parameters that have to be set correctly and you have to start from the correct record in users.
Your relationship is problematic, as philmodjunk pointed out.
You should relate your tables via a true primary key (UUID or auto-enter serial, unique, not empty, modification not allowed) and a foreign key field.
If you have a housekeeping field in your tables Auto-enter on creation, AccountName, then you can make a calc field in your parent table = Get (AccountName) matched to the CreatedBy field in your child table.
Then your GTRR will get you what you are looking for.
Thanks for your suggestions.I have changed the database a little now.
For table SampleInfo,I added_pkIndex as primary key which is automatically generated and adeda new field accountname which gets account name of the user.
For table Users,_pkUsername is the primary key.
I want to write a script which should find all the records which has same accountname.
I am using the below script now,but this deletes the other record rather than finding the related record.
No it doesn't. There's nothing in that script that deletes anything.
It should find all SampleInfo records that have the current user's account name in the SampleInfo::accountname field--that would seem exactly what you want here.
So you are still relating your tables by first name, which is not a good idea...no, I'll say it: It's a very bad idea. What if you have two records where the first name is John? What are the odds of that happening?
You have created a primary key and a foreign key, but they aren't being used. Instead of relating by first name, link the Primary key of your parent (one) table to the foreign key in your child (many) table. Really no point in going further until you fix that.
Please describe the layout and what you mean by "deleting". There is nothing in your script that deletes any records. Perhaps you mean "omitted" where you say "deleted"?
Also note that adding or modifying an auto-enter field does not update existing records automatically. You thus may need to examine the actual data in your account name field to determine why records aren't being found.
Thanks..I am getting the output now. I missed writing a script for showing all records in admin layout,I had just kept as Go to the layout.