Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2009
    Location
    Northern Ireland
    Posts
    2

    Unanswered: Can an If statement return multiple values in a function??...HELP

    Hi guys, first post and wondering can you help me?

    I have an input form which is working no problem, within this form there are several text boxes that are transparent and also locked. This is the call for the function:-

    If Validform = False Then
    MsgBox "You cannot enter a field with bad information"

    ElseIf Validform = True Then

    With rstAdd
    .AddNew
    !ACCOUNT_REF = Me!ComboAccount_ref
    !Sub_Start_Date = Me!Sub_Start_Date
    ..... etc

    I have a function that validates the form to make sure that values have been inputed into the appropriate fields. If the field has nothing in them and tried to insert the record the following function fires and is supposed to input information into the transparent boxes making them tell the user to input the information:-

    Function Validform() As Boolean

    If IsNull(Me!ComboAccount_ref) Or Me!ComboAccount_ref = "" Then
    Validform = False
    'MsgBox "Please enter an account ref"
    Me!erroraccref.Value = "* Required *"
    End If

    If Me!Product_Type = 1 And IsNull(Me!Postal_Sort) Then
    Validform = False
    'MsgBox "Please enter the Postal Sort"
    Me!errorprodtype.Value = "* Required *"
    End If

    If Me!Sub_End_Date = "" Then
    Validform = False
    'MsgBox "Please enter the Postal Sort"
    Me!errorsubend.Value = "* Required *"
    End If

    If Me!Address_Ref = "" Then
    Validform = False
    'MsgBox "Please enter the Postal Sort"
    Me!erroraddref.Value = "* Required *"
    End If

    If Me!Product_Type = "" Then
    Validform = False
    'MsgBox "Please enter the Postal Sort"
    Me!errorprodtype.Value = "* Required *"
    End If

    If Me!Delivery_Method = "" Then
    Validform = False
    'MsgBox "Please enter the Postal Sort"
    Me!errordelmeth.Value = "* Required *"
    End If

    If Me!Delivery_Frequency = "" Then
    Validform = False
    'MsgBox "Please enter the Postal Sort"
    Me!errordelfreq.Value = "* Required *"
    End If

    If Me!Region_Code = "" Then
    Validform = False
    'MsgBox "Please enter the Postal Sort"
    Me!errorregcode.Value = "* Required *"
    End If

    If Me!Current_Status = "" Then
    Validform = False
    'MsgBox "Please enter the Postal Sort"
    Me!errorcurstat.Value = "* Required *"
    End If

    End Function

    When the function fires, it just returns the first value required and doesnt make all the text boxes have "*Required *" in them. Do I need to put these in a loop or what is the correct syntax to return all the correct values....

    Any help would be great, cheers in advance guys!!!

    Last edited by adam2695; 07-15-09 at 11:00.

  2. #2
    Join Date
    Jul 2009
    Location
    Northern Ireland
    Posts
    2

    Thumbs up Got it!!!!

    Sorry guys, should have been an IsNull instead of the = ""

    Thanks anyway

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •