Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA 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 February 3rd, 2007, 11:18 PM
Registered User
Join Date: Jul 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default copy fields from Form to new form - openargs

the control on the separtate edit form is
    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "Sales Enquiry Register1"

    DoCmd.OpenForm stDocName, , , , acFormAdd, , Me![Enquiry/Quote] ' open argument

When the new form opens, it is a separate form, the "OnOpen" event is
    Dim dbs As DAO.Database
    Dim rst As DAO.Recordset
    Dim strsql As String

    Set dbs = CurrentDb
    strsql = "SELECT * FROM [Sales Enquiry Register] "
    strsql = strsql & "WHERE [Enquiry/Quote] = " & CLng(Me.OpenArgs)

    Set rst = dbs.OpenRecordset(strsql, dbOpenDynaset)
    If Me.OpenArgs And Len(Trim(Nz(Me.OpenArgs, ""))) > 0 Then
        'do something
        Me![Ref] = rst.Fields![Enquiry/Quote]
        Rem Me!Ref = OpenArgs
        'do something
        End If

The idea was to use openargs and populate the new form with data from the old.
Its a quote revision.
The new form has a new number and the ref field has the old number in it.
Trouble is on the line
Me![Ref] = rst.Fields![Enquiry/Quote]

I get an error 2448 that you can't assign a value to this object.

The underlying table is common to both forms.

Help required.

Old February 4th, 2007, 01:28 PM
Registered User
Join Date: Feb 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts

Hi Bill,

Here is how I go around this.

When you open the new form dim variables for each of the fields that you want to come over to the new form.

Close the original form.

Set the fields in your new form to the variables that you created.



Similar Threads
Thread Thread Starter Forum Replies Last Post
Form Fields Terry J Daichendt JSP Basics 2 September 15th, 2008 05:53 PM
copy a list box from a form to a report bjcountry Access 1 April 18th, 2008 03:14 PM
Copy auto number value to another form bamajog Access 11 February 10th, 2006 10:24 AM
copy int from form to other form q8z Beginning VB 6 0 November 4th, 2004 03:59 AM
Getting the submitted fields in a form siraj_java Javascript How-To 0 August 26th, 2003 12:38 AM

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