Results 1 to 4 of 4
  1. #1
    mjj4golf is offline Novice
    Windows 10 Access 2016
    Join Date
    Jan 2017
    Location
    Raleigh North Carolina
    Posts
    9

    If… End if problem.

    I am trying to write a subroutine for the after update control on a text box.
    Anyway, below is part of the cold I am using and I get a compile error saying that I have no block if. Which I assume means that the if and the End IF's don't match up. I just don't see it!

    If IsNull([PhoneExist]) Then
    message = "Please enter a phone #!"
    Else
    With rstParents
    .MoveFirst
    .FindFirst "[Phone] = Me![Phone]"
    If Not .NoMatch Then
    Me![Mother's Name] = ![Mother's Name]
    Me![Mother's Name] = ![Father's Name]
    rstStudents!ParentID = rstParents![ID]
    End If
    End If

    End Sub

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    It's deceptive. There's no End With.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    i dont see what this code is supposed to do..
    dont use .findfirst, instead you should really use
    me.filter = "[field]='" & me.textbox & "'"
    me.filterOn =true

    but the code you sent:
    Code:
    Public Sub test()
    If IsNull([PhoneExist]) Then
    Message = "Please enter a phone #!"
    Else
        With rstParents
            .MoveFirst
            .FindFirst "[Phone] = Me![Phone]"
            If Not .NoMatch Then
                Me![Mother's Name] = ![Mother's Name]
                Me![Mother's Name] = ![Father's Name]
                rstStudents!ParentID = rstParents![ID]
            End If
        End With
    End If
    End Sub

  4. #4
    mjj4golf is offline Novice
    Windows 10 Access 2016
    Join Date
    Jan 2017
    Location
    Raleigh North Carolina
    Posts
    9
    Thank you for the replies. I did have the End With but it was in the wrong place. ranman256: why shouldn't I use the findfirst statement?

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 9
    Last Post: 07-06-2015, 01:47 AM
  2. Replies: 2
    Last Post: 10-31-2012, 11:52 AM
  3. Replies: 2
    Last Post: 06-14-2010, 03:25 PM
  4. query problem i have a problem wi
    By maxx3 in forum Queries
    Replies: 0
    Last Post: 06-29-2009, 02:29 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums