Wrox Programmer Forums
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 3rd, 2007, 03:22 PM
Registered User
 
Join Date: Apr 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Copying part of a record

Hi,

I need to create a command button on a form that will only copy specific fields from the current record, and paste them as a new record. However, I cannot figure out how to specify fields, only the entire record. How can I do this?
 
Old April 3rd, 2007, 04:02 PM
Friend of Wrox
 
Join Date: Feb 2007
Posts: 163
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Are you creating a new record on the form bound recordset or are you opening the recordset yourself?

Let's assume you want "Customer Name" and "Customer Address" copied to a new record when the button is pressed and you're working with the recordset bound to the form:

-----------------------------------------------------------------------------------------
Private Sub CreateNew_Button_Click()

  Dim sCustName As String, sCustAddr As String
  sCustName = [Customer Name]
  sCustAddr = [Customer Address]
  me.recordset.AddNew
  [Customer Name] = sCustName
  [Customer Address] = sCustAddr
  ****Other Code Manipulations****
end sub
-----------------------------------------------------------------------------------------

 
Old April 3rd, 2007, 05:45 PM
Registered User
 
Join Date: Apr 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ok that works the way I need. the only problem now is that there are times when some of those fields that need to be copied are blank; they aren't always filled in. So then I will get an "Invalid use of Null" error. How can I avoid this?

EDIT: I found that using the Nz() function seems to take care of it.
ex) strClient = Nz([Client])





Similar Threads
Thread Thread Starter Forum Replies Last Post
Copying DOCTYPE madanshah16 XSLT 1 August 18th, 2007 12:23 PM
Copying images arnabghosh PHP How-To 1 February 21st, 2006 07:49 AM
Record locking - user needs the next queued record cbtoolkit SQL Server 2000 0 December 6th, 2004 08:29 AM
Copying some part of the doc using macro in word Lakshmi KS Access VBA 2 December 5th, 2003 05:36 AM
Copying a File, How? xgbnow Visual C++ 3 September 16th, 2003 03:37 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.