Populate field in one form from text box in another form

CanWest

Registered User.
Local time
Today, 07:38
Joined
Sep 15, 2006
Messages
272
I swear my brain has left me for a trip to China or something.

There are two forms invoolved in thi
pfrm_AddClientPrimary
pfrm_AddClientDuplicateCheck

On a command button in pfrm_AddClientDuplicateCheck I have the following code.

Code:
Private Sub cmdAddNewClient_Click()

    DoCmd.OpenForm "pfrm_AddClientPrimary"
    DoCmd.Close acForm, "pfrm_AddClientDuplicateCheck"

End Sub

This works great

On the onOpen event of the pfrm_AddClientPrimary form I have this code
Code:
Private Sub Form_Open(Cancel As Integer)

    Me.FirstName = Forms!pfrm_AddClientDuplicateCheck!txtFirstName
    Me.LastName = Forms!pfrm_AddClientDuplicateCheck!txtLastName
    Me.SocialInsureanceNumber = Forms!pfrm_AddClientDuplicateCheck!txtSOcialInsureanceNumber

    Me.FirstName.SetFocus
       
End Sub

This fails on the first line with this error
Run-time error 2147352567 (80020009)
You can't assign a value to this object

I am aware of the incorect spelling of Me.SocialInsureanceNumber this is the way it is in the db

I have done a lot of reading on this forum and others and none seem to apply to my situation.

Any assistance will be greatly appreciated
 
Me.Firstname might have a ControlSource that is not bound to a field. The form may be bound to a RecordSource that is not updateable.

However I do wonder why you are copying this information because it could be a normalisation error
 
Me.Firstname might have a ControlSource that is not bound to a field. The form may be bound to a RecordSource that is not updateable.

However I do wonder why you are copying this information because it could be a normalisation error

The purpose of the copy is to create a new record using pfrm_AddClientPrimary/ pfrm_AddClientDuplicateCheck shecks to see if the client already exists. If not then the value of those three text boxes are to be transfered to pfrm_AddClientPrimary

The fields are bound. The form is bound. The datasource is writable.
 
Should work. Can you upload a sample database with the forms?
 
Should work. Can you upload a sample database with the forms?

I have created a smaller version of the db with the two forms in question and the clients table (tbl_Clients)

If you open pfrm_AddClientDuplicateCheck and Type John as the first name you will see that the form is filtered to show that there is a John in the table, Then reset the form and type another name and then click the add button the other form opens and should populate the same fields with whatever was in the previous form.

I hope this makes sense
 

Attachments

Last edited:

Users who are viewing this thread

Back
Top Bottom