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!

Access 2007 - Copy Record and Append to New Record

Status
Not open for further replies.

BShick5088

Technical User
Jan 21, 2011
2
US
Hi,
I hope this is a simple question. I have a request to add a button on a form that will copy several data fields from the form into a new record. The Project Number is a primary key and will not allow duplicates. In the examples I have they all call for a complete append of the record and it errors out because it is creating a duplicate record in that field...

Is there a way I can DIM out about a dozen data fields then write them into a new record that would then prompt for a new Project Number?

I am pretty good at adapting code to fit what I need, but not at writing code if it goes too far off my examples from previous databases. So please if you can give me an example of what the code would look like then I should be able to make it work.

Thanks so much for any help!
Brian
 
Assuming lots of items etc>
Code:
Dim strSQL as String
strSQL = "INSERT INTO tlbNoNameGiven (field1, field2, field3, field4) " & _
 "Values (" & Me.txtNumericValue & ",""" & Me.txtStringValue & """, #" & _
 Me.txtDateValue & "#," & Me.txtAnotherNumericValue & ")"
Debug.Print strSQL
Currentdb.Execute strSQL, dbFailOnError

Duane
Hook'D on Access
MS Access MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top