return value

  • Thread starter Thread starter Sergey Bogdanov
  • Start date Start date
S

Sergey Bogdanov

Hello,

Is it possible to retrieve the return value from the certain opened dialog?
 
Sergey

There are several ways of dealing with this, The following is one method;

In the form 'Bills', I'll assume you've got an OK button to accept what's
been entered and that this currently closes the 'Bills' form

Instead of closing the form, 'hide' it;

Me.Visible = False

When a form is opened in dialog mode, the calling code halts until the form
is closed or hidden, so in your calling code add the following;

DoCmd.OpenForm stDocName, , , stLinkCriteria, , acDialog
If IsLoaded("Bills") Then
Me.tbBillsValue = Forms("Bills")!controlName.Value
DoCmd.Close acForm, "Bills"
End If

The IsLoaded function is a routine from the Northwind database installed
with all versions of Access;

Function IsLoaded(ByVal strFormName As String) As Boolean
' 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

You need to test for the Bills form being loaded as it may have been closed
rather than 'hidden' using the OK button code above.

HTH

Andy
 
Back
Top