Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Required Fields on existing records 2

Status
Not open for further replies.

midiman69

Technical User
Apr 27, 2005
34
GB
Can any one offer some advice on this.

I have a form that has one required field, this form has a subform based on a Tblmanufacturers, this contains 6 fields - 4 imported via ODBC from an AS400, 2 contained in the database. The 4 ODBC fields may or may not contain data.
I want to have a button that will either open another form if all fields on the subform are filled or display a message box if not. The fields are not tagged as required on the table as they may not be filled in on the AS400.
Can anyone suggest a way I can do this?

Thanks in advance
 
Sure. In the button's click event procedure, something like this:
Code:
If IsNull(Me!SubFormControlName.Form!Field1) Or _
IsNull(Me!SubFormControlName.Form!Field2) Or _
IsNull(Me!SubFormControlName.Form!Field3) Or _
IsNull(Me!SubFormControlName.Form!Field4) Then
    MsgBox "Required data missing.  Please enter data and try again."
    Else
        DoCmd.OpenForm "NameOfForm"
End If

HTH,

Ken S.
 
Hi
How about:
Code:
Dim ctl As Control
Dim Incomplete As Boolean

'Default to completed subform
Incomplete = False

'The name of the subform as shown by Me.
For Each ctl In Me.Tblmanufacturers_subform.Controls
'Assuming all valid controls are textboxes
    If ctl.ControlType = acTextBox Then
        If IsNull(ctl.Value) Then
            Incomplete = True
        End If
    End If
Next ctl

If Incomplete Then
    MsgBox "Please fill in the sub form"
Else
    DoCmd.OpenForm frmForm
End If
 
Thanks for the help guys.

I forgot to mention that the 4 AS400 fields are read only - I only need to detect if they are empty - the must me entered on the AS400 not through access. I will give you advice a go. Many thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top