Farey Ferrai
Farey Ferrai

Reputation: 29

Access one form open at a time

What can i do for this?

I want make MS access open only one form at a time. This means i have landing form as main form and when i open another form from button in main form, the main form should close and keep only the form i open. Likewise, when i close this form with close button, it should return back to home form.How can this be done? I have tried using Macro, but macro only allows to open main form but does not close main form when i open another form. Any help would be much appreciated.

Upvotes: 0

Views: 862

Answers (1)

Brian Pressler
Brian Pressler

Reputation: 6713

You can open the form in dialog mode, which will allow the user to only work in that form until it is closed. Any other forms will remain on the screen behind it though, but the user can not bring them into focus until the dialog form is closed.

So on your main form, you have a button to open the form. In the property sheet, click the event tab. Select the ... and choose "Code Builder". Then edit the on click procedure to look something like:

Private Sub btnOpenMyForm_Click()
On Error GoTo Err_btnOpenMyForm_Click

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "frmMyForm"
    DoCmd.OpenForm stDocName, acNormal, , , , acDialog

Exit_btnOpenMyForm_Click:
    Exit Sub

Err_btnOpenMyForm_Click:
    MsgBox Err.Description
    Resume Exit_btnOpenMyForm_Click

End Sub

if you use the button wizard, it will create code very similar to this... you just need to add the acDialog constant to the parameter of the OpenForm method.

Upvotes: 1

Related Questions