multi tab control

  • Thread starter Thread starter JulieD
  • Start date Start date
J

JulieD

hi all

i have a form with multi-tab control on it - the first page is made up from
fields from 1 table, the other pages are sub-froms created from other tables

what i want to do is ensure that when the user leaves the first page that
all fields are entered and that they can't do anything else on the other
pages until it is.

i can't seem to find anything in the events that capture this - unless i put
code (or a call to code) against each of the "on click" events of each of
the multi-tab pages.

Is there anyway of disabling the different pages until all the fields on the
first have been entered - maybe a NEXT button or somesuch.

Regards
JulieD
 
If the user must always enter something into particular field(s), mark them
as required:
1. Open your table in design view.
2. Select a field that must have an entry.
3. In the lower pane, set the Required property to Yes.
4. Repeat steps 2 and 3 for other fields.
5. Save the table and close.

Access will try to save the record before allowing the user to move into one
of the subforms. If a required field is blank, it save will fail until they
enter something.

If you wanted to warn the user that a field was blank, but allow the entry
anyway, use the BeforeUpdate event procedure of the main form:

Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim strMsg As String

If IsNull(Me.[SomeField]) Then
strMsg = strMsg & "SomeField is blank." & vbCrLf
End If

If IsNull(Me.[AnotherField) Then
strMsg = strMsg & "AnotherField is blank." & vbCrLf
End If
'etc.

If Len(strMsg) > 0 Then
strMsg = strMsg & vbCrLf & "Proceed anyway?"
If MsgBox(strMsg, vbYesNo+vbDefaultButton2, "Missing stuff") <>
vbYes Then
Cancel = True
End If
End If
End Sub
 
Hi Allen

i am aware of the setting the required property to "yes" but i was hoping to
do it another way as the error messages produced by access if they don't
entered something when required is pretty "yucky".

In addition, i want to default (after the event) fields that don't have an
entry in them to "not supplied" - for this, i think the code you supplied on
the before update event on the form might be worth a try.

Regards
julieD
Allen Browne said:
If the user must always enter something into particular field(s), mark them
as required:
1. Open your table in design view.
2. Select a field that must have an entry.
3. In the lower pane, set the Required property to Yes.
4. Repeat steps 2 and 3 for other fields.
5. Save the table and close.

Access will try to save the record before allowing the user to move into one
of the subforms. If a required field is blank, it save will fail until they
enter something.

If you wanted to warn the user that a field was blank, but allow the entry
anyway, use the BeforeUpdate event procedure of the main form:

Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim strMsg As String

If IsNull(Me.[SomeField]) Then
strMsg = strMsg & "SomeField is blank." & vbCrLf
End If

If IsNull(Me.[AnotherField) Then
strMsg = strMsg & "AnotherField is blank." & vbCrLf
End If
'etc.

If Len(strMsg) > 0 Then
strMsg = strMsg & vbCrLf & "Proceed anyway?"
If MsgBox(strMsg, vbYesNo+vbDefaultButton2, "Missing stuff") <>
vbYes Then
Cancel = True
End If
End If
End Sub

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.
JulieD said:
hi all

i have a form with multi-tab control on it - the first page is made up from
fields from 1 table, the other pages are sub-froms created from other tables

what i want to do is ensure that when the user leaves the first page that
all fields are entered and that they can't do anything else on the other
pages until it is.

i can't seem to find anything in the events that capture this - unless i put
code (or a call to code) against each of the "on click" events of each of
the multi-tab pages.

Is there anyway of disabling the different pages until all the fields on the
first have been entered - maybe a NEXT button or somesuch.

Regards
JulieD
 
Back
Top