Update value on form dependent upon which form subform was opened from..

not_rich_yet

Registered User.
Local time
Today, 06:51
Joined
Mar 19, 2002
Messages
39
If that makes sense?

Say I have numerous forms, all of which can open FormB.

These numerous forms can all open FormB via a button click. I create a value on FormB which I would like added to a value on the form which FormB was opened from.

Beyond creating a seperate FormB for each of the numerous forms, is there an easier way of doing this with code?

Cheers,

nry
 
Create an unbound text box on FormB and name it txtOpenedFrom.

In the click event of the button on each from that opens FormB, set the value of FormB!txtOpenedFrom equal to the form name of the calling form.

For example, if Command1 on FormA opens FormB...

Sub Command1_Click()
docmd.openform "FormB"
Forms!FormB!txtOpenedFrom = "FormA"
End Sub

THen refer to txtOpenedFrom in a Select statement to determine the course of action...

Select Case txtOpenedFrom
Case "FormA"
'Perform some action
Case "FormC"
'Perform some action
Case Else
'Perform some action
End Select


Good luck!
 
Presumably then, I can then use the value from the textbox to refer back to the form FormB was opened from? I can't suss the syntax to do this though, any ideas?

nry
 
I think I originally misunderstood what you meant! I think the use of Forms("FormName") may be the neater way to do this, but for the life of me i can't work it out...

I've just tried you're suggestion and had no hassles so for now guess which way I'm gonna use!

Ta,

nry
 

Users who are viewing this thread

Back
Top Bottom