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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Duplicate post?

Status
Not open for further replies.

JZII

Technical User
Jan 26, 2001
37
SE
Hi...

I want to duplicate a post with x fields containing "Company name" "adress" "contact" "cell" "fax"
and so on... I want to duplicate that post but not the "cell" post, that I want to be empty...how do I do that?


thanks! JZII
 
Put a button on the form (Call it cmdCopyPost). Code the On Click event of the button thus:

Private cmdCopyPost_Click()

DoCmd.RunSQL("INSERT INTO tblPosts ([fldCompanyName]" _
& ", [fldAddress], [fldContact], [fldCell], [fldFax]) VALUES " _
& "'" & Me![Company Name] & "', " _
& "'" & Me![Address] & "', " _
& "'" & Me![Contact] & "', " _
& "''," _
& "'" & Me![Fax] & ");")

End Sub
 
OK... This Is what i´ve done...but it doesn´t seem to work..
What is wrong...As you can see I have more posts than I told you before... On my button the onclick prefs are...


Private Sub cmdCopyPost_Click()

DoCmd.RunSQL ("INSERT INTO tblPosts ([Kategory]" _
& ", [Company], [Adress], [Zip], [Contact], [Phone], [Cell], [Fax], [E-mail], [Contact2], [Date], [Info]) VALUES " _
& "'" & Me![Kategory] & "', " _
& "'" & Me![Company] & "', " _
& "'" & Me![Adres] & "', " _
& "'" & Me![Zip] & "', " _
& "''," _
& "'" & Me![Phone] & "', " _
& "''," _
& "'" & Me![Fax] & "', " _
& "''," _
& "'" & Me![Contact2] & "', " _
& "'" & Me![Date] & "', " _
& "'" & Me![Info] & ");")

End Sub JZII
 
Almost...See the date field value...

Private Sub cmdCopyPost_Click()

DoCmd.RunSQL ("INSERT INTO tblPosts ([Kategory]" _
& ", [Company], [Adress], [Zip], [Contact], [Phone], [Cell], [Fax], [E-mail], [Contact2], [Date], [Info]) VALUES " _
& "'" & Me![Kategory] & "', " _
& "'" & Me![Company] & "', " _
& "'" & Me![Adres] & "', " _
& "'" & Me![Zip] & "', " _
& "''," _
& "'" & Me![Phone] & "', " _
& "''," _
& "'" & Me![Fax] & "', " _
& "''," _
& "'" & Me![Contact2] & "', " _
& "#" & Me![Date] & "#, " _
& "'" & Me![Info] & ");")

End Sub
 
Still doesn´t work... i get
"syntax error in INSTERT INTO statement"


??? JZII
 
Can´t anybody help me?

Please I need this... Is there an other option? JZII
 
Sorry about that. Don't stress - try this - It works for me.

Code:
Private Sub cmdCopyPost_Click()

    DoCmd.RunSQL ("INSERT INTO tblPosts ([Kategory]" _
          & ", [Company], [Adres], [Zip], [Contact], [Phone], [Cell], [Fax], [E-Mail], [Contact2], [Date], [Info]) " _
          & "VALUES " _
          & "('" & Me![Kategory] & "', " _
          & "'" & Me![Company] & "', " _
          & "'" & Me![Adres] & "', " _
          & "'" & Me![Zip] & "', " _
          & "'', " _
          & "'" & Me![Phone] & "', " _
          & "'', " _
          & "'" & Me![Fax] & "', " _
          & "'', " _
          & "'" & Me![Contact2] & "', " _
          & "#" & Me![Date] & "#, " _
          & "'" & Me![Info] & "');")
          
    Requery
    DoCmd.GoToRecord , , acLast
      
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top