Master detail- Same Table

I guys I need your help, I seem to have got suck again.

I have a table and a master detail form in which I am trying to create multiple records in the same table.

Table - Goals_Personal

ID - INT (AutoIncrement)
Employee_No (INT)
GID (INT)
Goal Title (VAR)

I need to first check if a record exist for Employee_No and GID.
Then if a record exists I want it to show
If Not then I need to add a new record (Master detail), that is linked to the Employee_No and Creates the next GID +1 up to a maximum of 5.

Here is what the form would look like

Main Form

ID = {2015001}
Employee_No = {234}
GID = {1}
Goal Title = {Increase sales revenue by 15%}

Master Detail - Goal 1

ID = {2015002}
Employee_No = {234}
GID = {2}
Goal Title = {Decrease costs by 15% in Toronto}

Master Detail Goal 2

ID = {2015003}
Employee_No = {234}
GID = {3}
Goal Title = {Increase customer satisfaction by 33%}

Does anyone know how to solve this?

Thanks a million,

Simona

Sorry Simona,

Your application decription is not clear for me. What I understand is that you have a table with employees with employeenumber, name etc…and want to have an overview (a grid) and the option to show the details of every employee (a form). Perhaps there are more tables, but the basic is to make a proper table in mySql (I expect you are working with MySQL).
What I see is this ID = {2015001} in your description. In PHP this means you want to add the content of {2015001} to something you call ID. This should be $ID (a variable).
When yes, should be something like $ID = 2015001; But I donot think you want that.
I think you want to fill a field ID in a table with 2015001. This is done by hand in the form and then pushing the button save. This for all the fields.
Or you want to import them from an Excel or something, then you can use the Scriptcase importer of write some PHP-code with an SQL-statement (INSERT INTO etc…)
The combination grid (the overview) and the form (details) is easy in SC…done with a link and some settings. But my advise is:
Start with making a proper the table (or tables) fill it with some data (still in MYSQL) and generate your grid and your form. Then the rest will come.
If this is the way to go, send me your tables and some content in it…(info@ctm-service.nl) and I have a look.

Regards, Bert Steinebach