Make form exclusive

Stemdriller

Registered User.
Local time
Today, 23:49
Joined
May 29, 2008
Messages
187
Hi all

When a certain button on a form is click it makes a sub form become visible, I am trying then to make this form exclusive aka, must be complete and stop the user clicking on the main form until this sub form has been complete.

I though it was something to do with show dialogue, I have done it b4 but simply cannot remember.

Any help greatly appreciated

Thanks

Gareth
 
A couple of ways to approach this:

1. Set focus on some part of the subform and loop through the controls & text boxes on the main form and set the enabled property to no.

2. Instead of using a subform, open as a seperate form and set the modal property to yes.
 
...I am trying then to make this form exclusive aka, must be complete and stop the user clicking on the main form until this sub form has been complete...
What you're saying, in essence, is that once a Record is initiated in the Subform, you don't want the user to be able to leave the Subform until that Record is complete, which means that this is a standard 'validation for Controls being populated' problem.

You don't say what constitutes a 'completed Record,' so there are a couple of possible solutions.

If only certain Controls need to be populated for a 'completed record,' something like this will work:

Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)

 If Nz(Me.Control1,"") = "" Then
   MsgBox "Control1 Must Not Be Left Blank!"
   Cancel = True
   Control1.SetFocus
   Exit Sub
 End If
 
If Nz(Me.Control2, "") = "" Then
   MsgBox "Control2 Must Not Be Left Blank!"
   Cancel = True
   Control2.SetFocus
   Exit Sub
 End If

End Sub
To validate all Fields as being populated:

Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)

Dim ctl As Control
Dim CName As String


For Each ctl In Me.Controls
    Select Case ctl.ControlType
        Case acTextBox, acComboBox, acCheckBox
            If Nz(ctl, "") = "" Then
              CName = ctl.Controls(0).Caption
              MsgBox "Following field is required: " & vbCrLf & CName
              Cancel = True
              ctl.SetFocus
              Exit Sub
             End If
    End Select
Next ctl

End Sub
Linq ;0)>
 
Thanks all for your replies, the subform becomes visible so it is already open so the code DoCmd.OpenForm "myform", acNormal, , , , acDialog is not valid, how can i change this code to work when the subform becomes visible.

I have tried on GotFocus but alas no luck.

Thanks

GW
 
...must be complete and stop the user clicking on the main form until this sub form has been complete...
To insure that once a New Record has been started in the Subform
it is completed, before leaving the Subform, all you need is the validation type code, as previously given.

You don't really want the user to click on the Subform, realize that they've made a mistake, and not be able to leave the Subform, do you?
 

Users who are viewing this thread

Back
Top Bottom