Use a radio button to select record to edit

Hi all

Scenario, 2 people dealing with records, person1 enters record with add screen which updates tab1
person2, deals with the record in table1, when they have done there job, the record is moved into table 2 and archived with a complete flag.

I am sure I could do this with 1 table but I need to do it this way to suit a business need.

so lets say I have 2 tables,

tab1 has fields
init, surname, date(ymmdd)
tab2 has fields
init, surname, date(ymmdd), complete

I already have the page for person1 setup and writing to a sql db.
For person 2, I need 2 screens, 1st one that scans table1 for records, a sort would be nice perhaps by date
Records should be presented as a 1 liner so lets say name only  (Brief) with a radio button next to them so person2 can select with the radio button the record to retrieve, pass the record to a 2nd screen where the whole detail is shown. Whn person2 is happy, they push a button on the screen and the details are moved from table1 to table2.
Any thoughts please, this is mega urgent, but then arnt they always!
thanks
Gary
LVL 1
123dec45Asked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
mms_masterConnect With a Mentor Commented:
Hi,

>"a sort would be nice perhaps by date"
You can sort your results by adding ORDER BY {field} {order}  replacing {field} with the field name and {order} with ASC for ascending order and DESC for descending order
e.g.
ORDER BY date ASC
or
ORDER BY date DESC

> "with a radio button next to them so person2 can select with the radio button the record to retrieve"
You need to add a field in table 1 called "id", set the type to int, set it as the primary key and set it to auto increment.
Then add same field in table 2, but this time DONT set it to auto increment.
The value of the radio buttons can then be set to the id of the record. The id can then be passed to the next page in order to retrieve the right record.

I've given an example of the SQL queries you can use below (I done them off the top of my head and haven't tested them, if theres any problems or you need more help with them let me know). I couldn't give you the code for displaying the results as I don't know which language your pages are using. (i.e. php, asp etc)
Page 1:
 
Retrieve details:
SELECT id, surname, date FROM table1 ORDER BY date ASC
 
Page 2:
 
Retrieve details:
SELECT * FROM table1 WHERE id = {id passed from page 1}
 
Copy details to table2:
INSERT INTO table2(id, surname, date) VALUES({id passed from table 1}, {surname passed from table1}, {date passed from table1})
 
Delete details from table 1:
DELETE FROM table1 WHERE id = {id passed from page 1}

Open in new window

0
 
RouchieCommented:
You could always do this in one operation directly within the database.  Something like

INSERT INTO tab2
 (init, surname, date, complete)
SELECT
 init, surname, date, @completeValue
FROM
 tab1
WHERE
  ??? = ???

DELETE FROM tab1 WHERE ??? = ???

The question marks allow you to add your own where clause, as I don't know how you are identifying the records to move.


Second approach would be to use a server-side language.  Show all records from tab1 on the page with a submit button that copies the individual record to the second table, and then delete from tab1.  Which server-side language are you using?
0
 
123dec45Author Commented:
Thanks Rouchie
ASP was the plan, the reason i wanted 2 tables was more from a security side, in the real world, table 1 will have limited information, table 2 sensitive info. The auditors I know will be happier if I can lock down table 2 by usernames or groups rather than trying to do it progromaticaly.
cheers
Gary
0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
RouchieCommented:
Create a recordset in DW and list all the names from tab1.  Add a checkbox to each repeat region so that when the page is submitted the receiving page receives a list of check boxes that are checked,

  i.e. "5, 7, 8, 12, 15, 17"

SQL Server can accept this as a stored procedure argument and turn the numbers into a temporary table, which can then very easily be copied over to tab2.  The first job is to create the list of records from tab1.  See how you get on with that and we'll take it from there!
0
 
123dec45Author Commented:
Thanks for the ideas, will give both a try and be back in the morning,.
thanks
g
0
 
123dec45Author Commented:
Nice... Sorry its taken some time to get back, always firefighting !!Worked like a drema, thanks for your help
br
GAry
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.