Andy Lacey
andy at minstersystems.co.uk
Wed Jan 21 11:53:46 CST 2004
Oleg, just do it your DAO loop, so With rs Do Until .EOF strLine = ![Employee Name] strLine = Proper(strLine) a = InStr(strLine, ",") FName = Mid(strLine, a + 2) LName = Left(strLine, a - 1) .Edit !Lastname=Lname !FirstName=Fname .Update .MoveNext Loop End With Andy Lacey http://www.minstersystems.co.uk > -----Original Message----- > From: accessd-bounces at databaseadvisors.com > [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of > Oleg_123 at xuppa.com > Sent: 21 January 2004 16:35 > To: accessd at databaseadvisors.com > Subject: [AccessD] Break Name > > > 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 > > > > _______________________________________________ > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/a> ccessd > Website: > http://www.databaseadvisors.com > >