Solved

Use a radio button to select record to edit

Posted on 2007-11-27
6
184 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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 …
This article is very specific and is only intended to help if you are installing Dreamweaver 8 in a Windows 7 environment with Office 2007 installed.   I'm not sure why Microsoft tends to release OS' that should not be released but they do.  Windows…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

912 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

21 Experts available now in Live!

Get 1:1 Help Now