materialstim
Technical User
Hi there,
I need to duplicate some of the fields on a data access page to carry them across to the next record. I'm building a database to monitor requests for non-destructive tests. Each submitted request has a work order and test pack number, which are common to groups of requests. Within each test pack there are several different welds that need tests. What I want to do is carry over the test pack number and work order number (plus various other fields) from the preceeding request to a new request, to save typing them in again each time. The system will primarily be used by people with no knowledge of Access, so I'm trying to keep it all web-based and easy to use, hence why I've ruled out the use of subforms. I've tried using the code on KnowledgeBase article ACC2000: How to Duplicate a Record on a Data Access Page, but get a syntax error. The relevant section of my code is as follows - any ideas where the error is?
<SCRIPT language=vbscript event=onclick for=cmdCopySQL>
<!--
dim sSQL
'Create a SQL statement with a WHERE clause to select the current record
sSQL = "INSERT INTO Integrity (MWONo, TPackNo, LineDwgNo, Size, Sch, WeldNo, WelderID) " & _
"SELECT MWONo, TPackNo, LineDwgNo, Size, Sch, WeldNo, WelderID " & _
"FROM Integrity WHERE ID = " & ID.value
'Run the SQL statement created above
MSODSC.Connection.Execute sSQL
'Requery the source for the page
MSODSC.CurrentSection.DataPage.Requery
'The MoveLast method will move to the last record
'in the recordset for the page. Depending upon the primary
'key for the underlying record source, this may not be the
'last record added.
MSODSC.CurrentSection.DataPage.MoveLast
</SCRIPT>
Thanks for your help - I'm newish to access so really appreciate it!
I need to duplicate some of the fields on a data access page to carry them across to the next record. I'm building a database to monitor requests for non-destructive tests. Each submitted request has a work order and test pack number, which are common to groups of requests. Within each test pack there are several different welds that need tests. What I want to do is carry over the test pack number and work order number (plus various other fields) from the preceeding request to a new request, to save typing them in again each time. The system will primarily be used by people with no knowledge of Access, so I'm trying to keep it all web-based and easy to use, hence why I've ruled out the use of subforms. I've tried using the code on KnowledgeBase article ACC2000: How to Duplicate a Record on a Data Access Page, but get a syntax error. The relevant section of my code is as follows - any ideas where the error is?
<SCRIPT language=vbscript event=onclick for=cmdCopySQL>
<!--
dim sSQL
'Create a SQL statement with a WHERE clause to select the current record
sSQL = "INSERT INTO Integrity (MWONo, TPackNo, LineDwgNo, Size, Sch, WeldNo, WelderID) " & _
"SELECT MWONo, TPackNo, LineDwgNo, Size, Sch, WeldNo, WelderID " & _
"FROM Integrity WHERE ID = " & ID.value
'Run the SQL statement created above
MSODSC.Connection.Execute sSQL
'Requery the source for the page
MSODSC.CurrentSection.DataPage.Requery
'The MoveLast method will move to the last record
'in the recordset for the page. Depending upon the primary
'key for the underlying record source, this may not be the
'last record added.
MSODSC.CurrentSection.DataPage.MoveLast
</SCRIPT>
Thanks for your help - I'm newish to access so really appreciate it!