Solved Ensure Data Entry

Thanks Minty....how would i disable the subform until there is the correct info in the main form ?
 
It's like everything starts working once i actually enter some information on the main form.
This - is exactly the point @Micron and I was making. If you don't enter anything there is no update, so the Before_Update event won't fire.
 
Thanks Minty....how would i disable the subform until there is the correct info in the main form?

Use the current event on the main form. Something like
Code:
If Me.Newrecord Then 
    Me.YourSubformControl.Enabled = False
Else
    If  ' do your other checks here as it not a new record;
    ' Other checks for valid data
     Me.YourSubformControl.Enabled = True
    end if
End if

Then in the before update event enable it if the data is present.
 
I just gave it a try bob....still lets me jump to the subform with the main form blank. I've just noticed that if i enter a name and then leave the Time blank, it prompts me to enter a time ? If i then enter a Time and go back and remove the name, it will prompt me to enter a name. It's like everything starts working once i actually enter some information on the main form.
I think Minty's comment:
I think the simple answer would be to disable the sub-form until there is data entered in the main form.
is the best solution.

The changes I suggested still allow the user to enter the sub form but the change to settings would prevent the record being saved
 
Ok i've tried the code below which is supposed to lock the subform until the main form is populated. It does lock the subform but it stays locked even after i fill in the controls on the main form. Can anyone see what i've done wrong ?

Code:
Private Sub Form_Current()
If IsNull([Forms]![frm_PlaceOrders]!OrderID) Then
With [Forms]![frm_PlaceOrders]!frm_SubOrders
.Enabled = False
End With
Else
With [Forms]![frm_PlaceOrders]!frm_SubOrders
.Enabled = True
End With
End If
End Sub
 
Ok i've tried the code below which is supposed to lock the subform until the main form is populated. It does lock the subform but it stays locked even after i fill in the controls on the main form. Can anyone see what i've done wrong ?

Code:
Private Sub Form_Current()
If IsNull([Forms]![frm_PlaceOrders]!OrderID) Then
With [Forms]![frm_PlaceOrders]!frm_SubOrders
.Enabled = False
End With
Else
With [Forms]![frm_PlaceOrders]!frm_SubOrders
.Enabled = True
End With
End If
End Sub
I think you'll need the code in the main forms After Update event as well.
 
Still locked bob...have it in the BeforeUpdate and FormCurrent
 
You may also need to do something to cause the main record to be saved, in which case you may need something like:
If Me.Dirty Then
Me.Dirty = False
End If
in the After Update event of the PickTime combo box
 
Sorry that's what i meant to write....it's in the AfterUpdate event
 
I think i found a solution. The code below works fine. It goes into the OnEnter event of the subform container

Code:
Private Sub frm_SubOrders_Enter()

If Len(Me.TodaysDate & "") = 0 Then
    MsgBox "You must select a date.", vbOKOnly, "Select Date"
    Me.TodaysDate.SetFocus
ElseIf Len(Me.cboSelName & "") = 0 Then
    MsgBox "You must enter your name.", vbOKOnly, "Enter Name"
    Me.cboSelName.SetFocus
ElseIf Len(Me.cbo_PickTime & "") = 0 Then
    MsgBox "You must pick a time slot.", vbOKOnly, "Select Time Slot."
    Me.cbo_PickTime.SetFocus
    
End If

End Sub
 
That's even better again arnelgp...thanks a lot. First thread i ever had where i came out with 2 solutions !.
Thanks again everyone for your help with this....i always appreciate it very much.

Em x
 

Users who are viewing this thread

Back
Top Bottom