Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Duplicating records on Data Access Page

Status
Not open for further replies.

materialstim

Technical User
Aug 8, 2007
2
US
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!
 
Just a bit more information to try and clarify things for you - the error is an Internet Explorer Script Error with the following details:

Line 174, Char 1, Error: Syntax error in INSERT INTO statement. Code 0

Line 174 refers to the following line in my code:

Code:
MSODSC.Connection.Execute sSQL

The version of Access I am using is Access 2003 SP2 (Build 11.6566.8132)

Cheers,

Tim.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top