How can I have field fill in automatically from one form to a 2nd

G

Guest

I'm using Access 2003, what I would like to do is that form A is filled out
and work completed so now form B will be filled out an linked to form A via a
project number, but I would like the project number from Form A to fill in
automatically when clicking on the command button to open form B.

For Example:

Project Update Form (form A) is open and the work is completed so now an ECN
(form B) is to be generated I would like the project number to fill in
automatically on the ECN form when clicking the Generate an ECN command
button from the Project update form.

The project update form number is a number that was automatically generated
by the database when the project was submitted and follows the project
through to full completion.

Is this possible? Or where can I look to find the information, I would like
to have the forms fill out automatically as much as possible to make life
just a little easier for the project coordinators.

Thank you in advance
 
B

bhipwell via AccessMonster.com

On the onopen event of form B:

Me.FieldFormB = Forms([FormA]).Controls([FieldFormA])

B
 
G

Guest

Okay, here's the code I put in but it keeps giving the error that it cannot
find the | field referred to in my expresson.

Code:

Private Sub Form_Open(Cancel As Integer)
Me.[PC-ECRNo] = Forms([FRM_ECR-Changes]).Controls([ECR_PC_No_ID])

End Sub

Me.[ECN form field name] = Form A information

Form b would be the ECN form field name and form A is the projects update
form. So I'm not sure why I'm getting this error but it appears I've missed
some step.

Thank you in advance.
 
B

bhipwell via AccessMonster.com

Try this. Notice no brackets on the first part and I replaced brackets with
""'s on the second part:

Me.PC-ECRNo = Forms("FRM_ECR-Changes").Controls("ECR_PC_No_ID")

B
 
G

Guest

When I enter the code as shown here;
Me.PC -ECRNo = Forms("FRM_ECR-Changes").Controls("ECR_PC_No_ID") I get this
error message:

Complie Error (Method or data member not found (error 461)

It highlights .Controls indicating that is where the errors is? I also
noticed it by default will put in spaces between PC and -ECRNo.
 
B

bhipwell via AccessMonster.com

Having underscores or dashes in field names is not a good idea since Access
uses those items for other processing indicators. If the .controls is
highlighted, it means that the field it is referencing cannot be found or is
an invalid data type. Double check to make sure all field names match and
that the field types are appropriate. If possible if you are not too far
into the program, consider renaming your table fields without hyphens and
underscores.

B
 
G

Guest

I will double check the field names. I know "now" that underscores/hyphens
are not a good idea but when this database was originally created about 2 1/2
- 3 or so years ago I was much less Access smart. Is there anyway around
this? I'm currently doing an update to the database, I currently don't use
those items any more. So now is there any way around it using brackets or
something?
 
G

Guest

Sorry it took so long to get back with this issue, but I took the time to
remove the underscores/hypens from the database.

Here is the code I'm using I have tried it with and without quotes and still
get this debug error "You can't assign a value to this object?" and it then
highlights the entire line of code. Could it be because the PROJECTID field
is an autonumber field?

Private Sub Form_Open(Cancel As Integer)

Me.ProjectNo = Forms(FRMProjectChanges).Controls(ProjectID)

End Sub
 
B

bhipwell via AccessMonster.com

Couple thoughts:

1) Is Me.ProjectNo a text field (not a label)?
2) Do the data types of the two fields match?
3) Is the Me.ProjectNo field tied to a field in a table? If so, make sure
the field type can accept the data from the field on the other form (text
will accept any information wheras a table field set to number or currency
can't accept all types of data).

Hope this helps.

B
 
G

Guest

Here are the answers:

1. The Me.ProjectNo is a number field (long integer)
2. The datatypes match they are both long integer fields the only
difference is one is a number (projectNo) and one ProjectID is an autonumber
field but both properties are set to long integer.
3. Both are tied to tables the ProjectNo is tied to the TBLECNIssued table
and the ProjectID is tied to the TBLProjects, and properties are set as
listed above long integer.
 
B

bhipwell via AccessMonster.com

Usually when you get the "Can't assign value to this object" either the field
trying to take in the data can't because of data type or there is a labeling
error. Try changing the field type in the table itself to double field size
and general number format.

B
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top