Solved

Use a radio button to select record to edit

Posted on 2007-11-27
6
182 Views
Last Modified: 2010-04-25
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
0
Comment
Question by:123dec45
  • 3
  • 2
6 Comments
 
LVL 25

Expert Comment

by:Rouchie
ID: 20357672
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
 
LVL 5

Accepted Solution

by:
mms_master earned 500 total points
ID: 20357762
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
 
LVL 1

Author Comment

by:123dec45
ID: 20357816
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 25

Expert Comment

by:Rouchie
ID: 20357871
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
 
LVL 1

Author Comment

by:123dec45
ID: 20360781
Thanks for the ideas, will give both a try and be back in the morning,.
thanks
g
0
 
LVL 1

Author Closing Comment

by:123dec45
ID: 31411177
Nice... Sorry its taken some time to get back, always firefighting !!Worked like a drema, thanks for your help
br
GAry
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

For those who don't know, Adobe Dreamweaver is a popular commercial web editor that enables you to design, build and manage complex websites. The editor is a WYSIWYG (What You See Is What You Get) web editor, which means that you can create your web…
I still run into .cgi files every now and then. In some instances, I actually prefer the simplicity of a .cgi script to other options. Since I use DreamWeaver extensively, what I needed was a way to open .cgi scripts in Dreamweaver. And I wanted to …
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now