return value

  • Thread starter Sergey Bogdanov
  • Start date
S

Sergey Bogdanov

Hello,

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

Andy Cole

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top