Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Copying a field from one form to another.

Posted on 2004-04-02
8
Medium Priority
?
1,024 Views
Last Modified: 2008-02-01
Hi everyone,

I would like to know if it possible to copy field from one form to another in the same database. I have form, that has "next" button on it, when clicked on it, a macro opens another form, and have it ready for me to add an entry, and closes the one it was on. I want to copy the customerID form A, to customerID in form b. The customerID in form A is auto number.

Kind regards,

Hassan
DHP, Inc.
http://www.dhp-inc.net
hassan@dhp-inc.net
0
Comment
Question by:haszan
  • 4
  • 2
  • 2
8 Comments
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 10742195
I take it that you are using Access?
0
 
LVL 1

Author Comment

by:haszan
ID: 10742217
Yes,i'm using access.
0
 
LVL 17

Accepted Solution

by:
walterecook earned 500 total points
ID: 10742521
Several ways to get there.
One is this for your open button

docmd.openform "yournewForm"
forms!yourNewForm!CustomerID = me.customerID
DoCmd.Close acForm, "OldForm"

Walt
0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 10742725
or you can pass the CustomerID to the second form using the OpenArgs parameter on the DoCmd.OPenForm:

DoCmd.OpenForm "yournewform",OpenArgs:=CustomerID

then in the Form_Open procedure of the New form:

Private Sub Form_Open(Cancel as Integer)

   CustomerID.Text = OpenArgs

End Sub

here I am assuming that you have a TestBox on the NEW form, named CustomerID.

AW
0
 
LVL 17

Expert Comment

by:walterecook
ID: 10742854
Yup.
That's a good way too.
Well done AW.
0
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 10743094
using OPenArgs assures that the form will open with the correct data.  Trying to pass the value AFTER the form is already open, may or may not result in the proper data being displayed.

AW
0
 
LVL 1

Author Comment

by:haszan
ID: 10750193
Hi again,

the way Walt suggested seem to work for me, but out of curiousity why wouldn't the way Arthur suggested work for me? the following is the error message i get.

"Run-time error '2185':

you can't reference a property or method for a control unless the control has the focus"

thanks and kind regards,

Haszan
0
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 10790287
becuase Access is rather retarded in that, in orrder to assign a value to a Property of a Control, THAT control MUST have 'focus'.  In full VB, that is NOT the case, and this line:

CustomerID.Text = OpenArgs


will work without problem in Full VB.  It was my mistake, as I normally code in VB 6 and VB.Net and not quite as much in VBA (in Access).  In Access, the line should have been:

CustomerID = OpenArgs

which makes use of the fact that, for a TextBox control. the TEXT property is the defualt, and thus it is NOT necessary to explicitly assign the value to the DEAFULT property, and this avoids the error message that you got, but accomplished precisely the same result.

Sorry about that.

AW

0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
In this article, I’ll look at how you can use a backup to start a secondary instance for MongoDB.
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

963 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question