Move data from one form to another

D

David Wetmore

How can I move data from one open form to another?

For example, the current form has a variable intHeaderKey. Suppose it contains 1234.
On another form, frmDestination, there is a public variable intImportedHeaderKey
I would like to be able to build a string like:
strCommand = "Forms!frmDestination.intImportedHeaderKey = " & Cstr(intHeaderKey)
and execute the string as VBA Command

Or is there a better way to do this?

Thanks,
Dave
 
E

ErezM via AccessMonster.com

hello
access (and vba for that matter) is event driven, and therefore, you need to
choose the right event during which the mentioned values can be passed from
form1 to form2.
let's say you choose the textbox (or other control) that is used to update
intHeaderKey in form1, then use this textbox's AfterUpdate event to forward
the new value to form2's textbox, intImportedHeaderKey like this

Private Sub intHeaderKey_AfterUpdate()
Forms!form2![intImportedHeaderKey]=intHeaderKey
End Sub

good luck
Erez
 
L

Linq Adams via AccessMonster.com

Also note that the receiving form has to be open at the time.
 

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