[AccessD] Break Name

Oleg_123 at xuppa.com Oleg_123 at xuppa.com
Wed Jan 21 10:34:30 CST 2004


Hey Group
I did a finction that separates names into first and last,and makes
propercase - ex. Name: "MCDONALD, REYNA" becomes FirstName: "Reyna"
LastName "McDonald" How can Insert the 2 new fields into the same table ?
I tried Update...



Public Function BreakName()


'Separate The Name field to Firs and LastName and ProperCase it
'Uses MDL-Proper Module


MsgBox ("hey")
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb

Dim strLine As String
Dim strSQL1 As String
Dim strSQL2 As String
Dim FName As String
Dim LName As String
Dim a As Integer


strSQL1 = "Select * From [emp table1]"
Set rs = db.OpenRecordset(strSQL1)


  Do Until rs.EOF
strLine = rs("Employee Name")
'
strLine = Proper(strLine)
a = InStr(strLine, ",")
FName = Mid(strLine, a + 2)
LName = Left(strLine, a - 1)

'rs(0) = strLine


  strSQL2 = "Update [Emp Table1] Set (LastName, FirstName) = Values(" &
"'" & FindAndReplace(CStr(LName), Chr(39), Chr(39) + Chr(39)) & "','" &
FindAndReplace(CStr(FName), Chr(39), Chr(39) + Chr(39)) & "')"
Debug.Print strSQL2

    CurrentDb.Execute (strSQL2)
    rs.MoveNext
  Loop

   MsgBox ("end")

End Function



-----------------------------------------
Get Breaking News from CNN, ABC, NBC, CBS Now.
http://www.xuppa.com/news/?link=webmail




More information about the AccessD mailing list