form linkage

J

jnewl

have a form with 4 sub forms. each sub form is from a different table and all
are linked by a key known as tax id.
have a command button, where i go to another form to retrieve additional
addresses for the organization. this information comes from an address table
and the key is tax id. in the query, i use the concept of forms![prev
form].[tax id].

all of this works fine. however, when i try to add an address by tabbing
down to a blank line, i can key street, city state... but i can not post the
tax id because on this screen, the tax id field is linked to the previous
screen.

how do i code, so i can post the tax id, along with the other fields, when i
key the new record?

thanks for your help
 
A

Allen Browne

Here is an example of the kind of code you could add to the address form's
Before Insert event procedure:

Private Sub Form_BeforeInsert(Cancel As Integer)
Const strcPriorForm = "prev form"
If CurrentProject.AllForms(strcPriorForm).IsLoaded Then
With Forms(strcPriorForm)![tax id]
If Not IsNull(.Value) Then
Me![tax id] = .Value
End If
End With
End If
End Sub

Substitute your previous form's name in the quotes on line 2. What the code
does is look to see if the other form is open and has a [tax id] value. If
so, it copies that value into the new address record.
 
J

jnewl

thanks much

Allen Browne said:
Here is an example of the kind of code you could add to the address form's
Before Insert event procedure:

Private Sub Form_BeforeInsert(Cancel As Integer)
Const strcPriorForm = "prev form"
If CurrentProject.AllForms(strcPriorForm).IsLoaded Then
With Forms(strcPriorForm)![tax id]
If Not IsNull(.Value) Then
Me![tax id] = .Value
End If
End With
End If
End Sub

Substitute your previous form's name in the quotes on line 2. What the code
does is look to see if the other form is open and has a [tax id] value. If
so, it copies that value into the new address record.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

jnewl said:
have a form with 4 sub forms. each sub form is from a different table
and all are linked by a key known as tax id.
have a command button, where i go to another form to retrieve additional
addresses for the organization. this information comes from an address
table and the key is tax id. in the query, i use the concept of
forms![prev form].[tax id].

all of this works fine. however, when i try to add an address by tabbing
down to a blank line, i can key street, city state... but i can not post
the
tax id because on this screen, the tax id field is linked to the previous
screen.

how do i code, so i can post the tax id, along with the other fields, when
I key the new record?
 

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