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

    .FindFirst results in the data type mismatch

    Hi again, I am trying to find a record using a phone number. The parents table has field for the phone number which is a short text. The form I use has an unbound
    text box for the input of the phone number. I then use the subroutine below to find out if a record exists with that phone number. But I get a daily type mismatch when I execute the .FindFirst I have researched access documentation and thought I was doing everything right but apparently I'm not. Can somebody please point out what I am doing wrong. Thank you in advance!

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


    rstStudents!ParentID = rstParents![ID]
    Me.Refresh
    End If
    End With
    End If

  2. #2
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Hard to tell without the whole subroutine here. You could also use a DLookUp which will give you the same result, except that then you would need to populate the fields - this could be accomplished by having a bound form and using a filter.

  3. #3
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    If the phone number is (Short)Text, the syntax should be

    "[Phone]= '" & Me![Phone] & "'"

    your syntax

    "[Phone]= " & Me![Phone]

    is only valid for a Field defined as a Number.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

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

Similar Threads

  1. Replies: 1
    Last Post: 12-05-2014, 07:41 PM
  2. data type mismatch
    By ottoc in forum Queries
    Replies: 1
    Last Post: 12-02-2014, 09:42 AM
  3. Data Type Mismatch
    By Mtyetti2 in forum Queries
    Replies: 3
    Last Post: 10-23-2013, 11:48 AM
  4. FindFirst Not Working with Decimal Data Type
    By JonMulder in forum Programming
    Replies: 5
    Last Post: 01-22-2013, 01:26 PM
  5. Data Type Mismatch
    By timmy in forum Programming
    Replies: 9
    Last Post: 04-12-2011, 03:48 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