Johnnycat1
Programmer
All,
I am trying to run some code that splits a Contact Name field into two separate fields. This is what I have so far. I don't usually manipulate data this way so I am stumbling around. Your help is greatly appreciated.
Excuse the table and field naming methods... This is a very old table that I created many years ago before learning an appreciation of good naming methods. I have too many links to this now and haven't spent the time to go back and re-name everything.
I am trying to run some code that splits a Contact Name field into two separate fields. This is what I have so far. I don't usually manipulate data this way so I am stumbling around. Your help is greatly appreciated.
Excuse the table and field naming methods... This is a very old table that I created many years ago before learning an appreciation of good naming methods. I have too many links to this now and haven't spent the time to go back and re-name everything.
Code:
If Nz(Me![To], 9) = 9 Then Exit Sub
If Nz(Me![Addresses-Contact Names Sub-Form]![Contact Name], 8) = 8 Then Exit Sub
Dim StXXX As String
Dim stContactName As String
Dim stFirstName As String
Dim stLastName As String
Dim rstOutlookContact As DAO.Recordset
StXXX = "XXX"
stContactName = Me![Addresses-Contact Names Sub-Form]![Contact Name]
stFirstName = Right$(Me![Addresses-Contact Names Sub-Form]![Contact Name], Len(Me![Addresses-Contact Names Sub-Form]![Contact Name]) - InStr(1, Me![Addresses-Contact Names Sub-Form]![Contact Name], ",") - 1)
stLastName = Left$(Me![Addresses-Contact Names Sub-Form]![Contact Name], InStr(1, Me![Addresses-Contact Names Sub-Form]![Contact Name], ",") - 1)
Set rstOutlookContact = CurrentDb.OpenRecordset("AddressBookTempOutlookContacts", dbOpenDynaset)
With rstOutlookContact
.FindFirst "[ID]='" & StXXX & "'"
.Edit
![LastName] = stLastName
![FirstName] = stLastName
![LastName] = stLastName
![ContactName] = stContactName
.Update
End With