Problem with Simple Code

Terry Lawson

Registered User.
Local time
Today, 17:27
Joined
Mar 1, 2010
Messages
12
All

I'm having a problem with the following very simple code the lines in red flatly refuse to trap a space followed by a lowercase letter.
I'm trying to write the first set of words that start uppercase to a different field (the first letter in the read field is always uppercase)


Option Compare Database
Option Explicit

Dim i As Integer

Dim rsData As Object
Dim strEntry As String
Dim strForenames As String
Dim strFullName As String
Dim strLastChar As String
Dim strPart As String
Dim strSurnamne As String


Private Sub Form_Open(Cancel As Integer)
Set rsData = CurrentDb.OpenRecordset("Rodmell Manorial")
With rsData
.MoveFirst
Do Until .EOF
strFullName = ""
strEntry = !entry
strLastChar = Left(strEntry, 1)

If Not IsNull(strEntry) Then
For i = 1 To Len(strEntry)
strPart = Mid(strEntry, i, 1)
If strPart = LCase(strPart) Then
If strLastChar = " " Then 'have lowercase letter following
GoTo dunnit
End If
End If

strFullName = strFullName & strPart
strLastChar = strPart
Next i
End If
dunnit:
.Edit
![Full Name] = strFullName
.Update

.MoveNext

Loop

End With



End Sub

Please could somebody tell me what I'm doing wrong.

Many thanks

Terry Lawson
 
Can you post a before and After example to see what you are hoping to get.
 
Access, unless you specify to compare binary will see "This String" and "this string" as equal. So at the top of your module put

Option Compare Binary
 
Sorry, forgot to mention - you have to remove the

OPTION COMPARE DATABASE

and REPLACE it with

OPTION COMPARE BINARY

for that module.
 
Bob and David

Immediate success with Option Compare Binary

Many thanks to you both (and I've clicked your personal thanks as well!)
I'm so impressed with the very rapid responses
Ain't it easy when you know how.

Regards

Terry Lawson
 

Users who are viewing this thread

Back
Top Bottom