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)
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)