Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I posted this question once before

Status
Not open for further replies.

lastout

Programmer
Apr 12, 2002
84
US
I posted this question once before but, alas, I dropped the ball on the thread, so I'm posting again.

I have a form, frmProperty, that can be opened via command buttons from two places: from the Switchboard and from frmOwner. When frmProperty is opened from the switchboard, the user is most likely going to be entering new data, so the OnLoad event of frmProperty has a DoCmd.GoToRecord...acNewRec. However, if the user is in frmOwner and is dealing, say, with owner Joe Brown, and wants to look at Joe Brown's property info in frmProperty, the user clicks a command button that opens frmProperty and takes the user to Joe Brown's property record.

Taken separately, either of these tasks are easy enough to accomplish, but to do both is not so easy. And there's a third wrinkle - frmProperty might already be open when the user is in frmOwner and wants to "activate" frmProperty and still go to the Joe Brown property record. In this case I can't use DoCmd.OpenForm.

But back to the first problem, if the user clicks the button to go to frmProperty from frmOwner and the OnLoad event of frmProperty goes to a new record, well, that's what they're going to see, a new record, not the Joe Brown record.

That makes me think I have to put an If...Then statement in frmProperty's OnOpen event that knows just where frmProperty was called from and so knows which record to go to. I tried using SysCmd..GetObjectState to determine whether or not frmOwner is open when frmProperty is opened and can get that to take me to a blank record if it finds frmOwner is closed. I'm not sure though if that's a good way to go about it. But if frmOwner is open, and presumably (maybe a bad assumption) frmProperty is being called from the button in frmOwner, I can't figure out how to cause frmOwner to find the matching record. I'm guessing it'll have to be a DoCmd.GoToRecord or DoCmd.FindRecord, but how do I specify which record? Do I need to store the linked field (PropertyID) from frmOwner in a variable somewhere and then refer to it in the arguments of the DoCmd? Or should I apply a filter using the variable? Or???

Also, should I be using the OnLoad, OnOpen, and OnActivate events of frmProperty?

Any answers, suggestions, advice, are all greatly appreciated!



lastout (the game's not over till it's over)
 
If the command button needs the new record, it is a piece of cake. Simply add the

DoCmd.GoRecord,, ac NewRecord (as I remember it) after the form open.

Rollie
 
I use the "TAG" property of the target form (frmProperty) and place the "calling form" identity in it. Which ever event you use can check the contentsmof the tag and determine the "CallerID", proceeding accordingly.

Re-WHICH event to use, I use form activate, as it will always be raised when the form is instantiacted, while form load is nnot raised if the form is already resident.

Another 'technique' you might consider in this situation is to save the current status (record (pointer)) if the form is already loaded when you call is and return to that status on exit. e.g. if the form was not loaded, then close it on exit. If it was displaying a particular record, return to that record, if it was in dataentry mode, additional decisions need to be made - should you save the (possibly incomplete record) and restore that, forsce the user to complete the entry (at least to a point), or abandon the record. After the decision, implement the 'corrcect' process.

MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
Thanks for replying. I found another solution that works fine which I may post after I've considered your suggestion. I suspect your suggestion might be better, more fool-proof and flexible. If I have a problem implementing it, I'll post again to this thread. Thanks! lastout (the game's not over till it's over)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top