Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2014
    Posts
    3

    Unanswered: Can you call code from an concentated field?

    I have a form with fields
    LastName
    FirstName

    and then a text box that brings them together FirstName &" " & LastName (I dont want to make FullName a data entry field - I want them separated)

    What is wanted, is a message box warning that is triggered if both fields are matched when a new customer is added.

    I have found some code and can get it to work when i call it from the AfterUpdate event of either LastName or FirstName (as individual entities) but not on the Full Name.
    Is there a way to call the code from the text box (txtFullName) that brings the fields together?

  2. #2
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    Because you're populating this Control using code, none of it's events will be triggered.

    How/where are you doing the concatenation? You could check for duplicates of the two Fields at this point, using DCount(), and act accordingly, or use DCount() in the Form_BeforeUpdate event, and use

    Cancel = True

    to stop the update, if that's appropriate, if a dup is found.

    The syntax for the DCount, to detect a duplicate, would be

    Code:
    If DCount("*","TableOrQueryName", "[FirstNameField]='" & Me.[FirstNameTextbox] & "' AND [LastNameField] ='" & Me.LastNameTextbox & "'") > 0 Then
    Linq ;0)>
    Last edited by Missinglinq; 01-16-15 at 01:05.
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  3. #3
    Join Date
    Jul 2014
    Posts
    3

    Duplicate field dilemma - good option

    Thanks - that has worked well

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    one of the problems with names is that there are different spelling, you also may need to cater for typo's.
    so an exact match may not be 'the' solution to this sort of problem[code]

    ..so what to do?
    well you could use, say, a combo or list box or even a modal form that displays any matches (or possible matches (say everyone with the same surname))
    you could use a SQL LIKE with a wildcard instead of =. eg:-
    Code:
    If DCount("*","TableOrQueryName", "[FirstNameField] like '*" & Me.[FirstNameTextbox] & "*' AND [LastNameField] LIKE '*" & Me.LastNameTextbox & "*'") > 0 Then
    you could use something like soundex or double metaphone to improve name matching. bear in mind soundex is more anglo saxon based, double metanome may get better results with non English names
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

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