Programmatically creating email, checking if exists - ADO DAO RDO RDS

This is a discussion on Programmatically creating email, checking if exists - ADO DAO RDO RDS ; Hello Guys, I'm trying to create (automatically) an email from a filled in sur- and lastname. Because a email could exists upon creating a new record, i'm checking if it exists, if it does, it should use another format. I ...

+ Reply to Thread
Results 1 to 2 of 2

Programmatically creating email, checking if exists

  1. Default Programmatically creating email, checking if exists

    Hello Guys,

    I'm trying to create (automatically) an email from a filled in sur- and
    lastname. Because a email could exists upon creating a new record, i'm
    checking if it exists, if it does, it should use another format. I have
    created three ways: in case of longer names that could be, for example:
    dirk.the.winner@hotmail.com, dirk.thewinner@hotmail.com or
    dirkthewinner@hotmail.com.

    Somehow it doesn't work as supposed to be. It does write down the email in
    the correct format: dirk.the.winner@hotmail.com, but if I try to create a
    second user with the same name (which could be), it keeps on creating
    dirk.the.winner@...

    I'm now guessing i'm doing this completely wrong... :-s...

    Suggestions?

    The code i've written for it:

    Private Sub txtLastName_AfterUpdate()
    If Not IsNull(txtSurName) And Not IsNull(txtLastName) Then
    txtEmail = (LCase(txtSurName) & "." & ReplaceWithDots(LCase(txtLastName)
    & "@emmaus.be"))
    If DCount("*", "Users", "Logonnaam = '" & txtEmail & "'") = 0 Then
    bldAddEmail = True
    End If
    txtEmail = (LCase(txtSurName) & "" & GetRidOfSpaces(LCase(txtLastName) &
    "@emmaus.be"))
    If DCount("*", "Users", "Logonnaam = '" & txtEmail & "'") = 1 Then
    blnAddEmail = True
    Else
    txtEmail = (LCase(txtSurName) & "." &
    GetRidOfSpaces(LCase(txtLastName) & "@emmaus.be"))
    blnAddEmail = True
    End If
    End If

    If blnAddEmail Then
    ' is Form based on the [Users] table?
    Me![Email] = txtEmail
    Cancel = False
    End If
    End Sub

    Public Function GetRidOfSpaces(TextIn)
    GetRidOfSpaces = Replace(TextIn, " ", "")
    End Function

    Public Function ReplaceWithDots(TextIn)
    ReplaceWithDots = Replace(TextIn, " ", ".")
    End Function

  2. Default Re: Programmatically creating email, checking if exists


    Private Sub txtLastName_AfterUpdate()
    If Not IsNull(txtSurName) And Not IsNull(txtLastName) Then
    txtEmail = (LCase(txtSurName) & "." & ReplaceWithDots(LCase(txtLastName)
    & "@emmaus.be"))
    If DCount("*", "Users", "Logonnaam = '" & txtEmail & "'") = 0 Then
    bldAddEmail = True
    Else ' <<<<<this line is changed
    txtEmail = (LCase(txtSurName) & "" & GetRidOfSpaces(LCase(txtLastName) &
    "@emmaus.be"))
    If DCount("*", "Users", "Logonnaam = '" & txtEmail & "'") = 1 Then
    blnAddEmail = True
    Else
    txtEmail = (LCase(txtSurName) & "." &
    GetRidOfSpaces(LCase(txtLastName) & "@emmaus.be"))
    blnAddEmail = True
    End If
    End If ' <<<<<this line is new
    End If

    Bill Manville
    MVP - Microsoft Excel, Oxford, England


+ Reply to Thread

Similar Threads

  1. Checking Get variable exists
    By Application Development in forum PHP
    Replies: 2
    Last Post: 09-17-2007, 11:17 AM
  2. Programmatically creating email (hyperlink) - BUG?
    By Application Development in forum ADO DAO RDO RDS
    Replies: 1
    Last Post: 09-04-2007, 04:30 AM
  3. Checking if the App.Config file exists
    By Application Development in forum DOTNET
    Replies: 1
    Last Post: 07-27-2007, 01:11 AM
  4. Checking if URL exists
    By Application Development in forum Javascript
    Replies: 5
    Last Post: 07-14-2007, 09:52 AM
  5. pre-windows 2000 logon name already exists when creating email account
    By Application Development in forum Microsoft Exchange
    Replies: 2
    Last Post: 03-17-2006, 08:39 AM