Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2004
    Location
    United Kingdom
    Posts
    56

    Unanswered: If statements to look at more than 1 field

    Hey guys,

    I have a button on a form that closes it and opens another. At the moment I have code in there to check that the user has entered data into a field called "Address1". Does anyone know how to get it to check other fields within the same piece of code - specifically in this case "Address2", i.e.

    If address1 is null OR if address2 is null then...

    The code I have used to check the single field is:

    Code:
    Private Sub labelProjects_Click()
    If IsNull(Me.address1) Then
    Me.Surname.SetFocus
    Me.address1.SetFocus
    MsgBox "Please enter data for Address1"
    Else
    DoCmd.Close acForm, "frmAddPerson"
    DoCmd.Close acForm, "PROJECTS2"
    DoCmd.OpenForm "PROJECTS2", acNormal, "", "", , acNormal
    DoCmd.Maximize
    End If
    End Sub

    Any ideas?

    Cheers,

    Rusty

  2. #2
    Join Date
    Sep 2004
    Posts
    161
    You wrote the solution, it only remains to translate it.

    If address1 is null OR if address2 is null then

  3. #3
    Join Date
    Sep 2004
    Posts
    161
    You wrote the solution, it only remains to translate it.

    If address1 is null OR (if) address2 is null then

  4. #4
    Join Date
    Apr 2004
    Location
    United Kingdom
    Posts
    56
    Thanks jepi, I guess the solution was staring me in the face.

    I used:
    If IsNull(Me.address1) Or IsNull(Me.address2) Then

    Works a treat!! Thanks,

    Rusty

Posting Permissions

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