Passing data if form is open

jfisher4

Registered User.
Local time
Today, 01:58
Joined
Oct 29, 2002
Messages
13
I have a form "workorder" that I want to be accessed two ways. One, open a new form with a button on the "customer" form. Two, through another form "estimate". The difficulty I'm having is that when opening from the estimate form I want the data from it to populate the workorder using the estimate number to link, but if an estimate has not been filled out first, the estimate number would be null and the form blank to allow data entry. Should I have two different on click events for the buttons, or should it be looking if the estimate form is open in its on open event? Hope this makes sense.
 
To my knowledge, you would have to do this in an Onopen event, or make 2 seperate forms.

I have a similar cases in some of my databases, and thus put the following function in a global module that I include in all my databases. It makes it easy to build conditionals based on if a given form is open.

You would use it easily as

If Isloaded("estimate") then
[some code]
end if



Function Isloaded(ByVal strFormName As String) As Integer
' Returns True if the specified form is open in Form view or Datasheet view.

Const conObjStateClosed = 0
Const conDesignView = 0

If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <> conObjStateClosed Then
If Forms(strFormName).CurrentView <> conDesignView Then
Isloaded = True
End If
End If

End Function
 
Thanks to you both. I'm still at a point where I have to really study it and break it down in my mind to envision how it will come together. I see it now. I will give it a try. Thanks again.
 
Waltang wrote:
To my knowledge, you would have to do this in an Onopen event, or make 2 seperate forms.
I know it was just presented as an option, but do not create 2 separate forms, unnecessary, and it will drive you nuts.

If you are on the estimate form and you find out that the workorder form is already loaded though, you still have to figure out if the estimate form has been filled out. You can determine that by looking for the estimate number. If it does exist, then you have to pass that somehow to the workorder form.

You cannot reliably do that with the OpenForm command since it won't work if the workorder form is already open. You need to run some code on the workorder form to look for an estimate number from the estimate form, and if it's already open, the Open event won't work, so you can place it in a public sub that you call from the estimate form.
 

Users who are viewing this thread

Back
Top Bottom