T
Tamer Seoud
I have a query in Access 97 that has a field containing a
space between the last and first name ex:Seoud, Tamer. I
want to eliminate the space. I realized that the replace
function will not work directly within the query, so I
made some changes to the Click event of the command button
that opens the query, the way to call the function. There
is something wrong with the declaration or with the logic
of the code. Can you please tell me what I'm missing here.
Thanks in advance.
The following are the VB code:-
Option Compare Database
Option Explicit
Public Function Replace(ByVal [qry_FPNamesMismatch]![NAME]
as field,ByVal _
" " as String,ByVal "" as String) As String
Dim Temp As String, P As Long
Temp = [qry_FPNamesMismatch]![NAME]
P = InStr(Temp, " ")
Do While P > 0
Temp = Left(Temp, P - 1) & "" & Mid(Temp, P + Len(" "))
P = InStr(P + Len(""), Temp, " ", 1)
Looop
Replace = Temp
End Function
Private Sub cmd_ViewQry_FPNamesMismatch_Click()
Dim StDocName As String
StDocName = "qry_FPNamesMismatch"
DoCmd.OpenQuery StDocName, acViewPreview, acEdit
call Replace (ByVal [qry_FPNamesMismatch]![NAME]as
field,ByVal _
" " as String,ByVal "" as String) As String
End Sub
space between the last and first name ex:Seoud, Tamer. I
want to eliminate the space. I realized that the replace
function will not work directly within the query, so I
made some changes to the Click event of the command button
that opens the query, the way to call the function. There
is something wrong with the declaration or with the logic
of the code. Can you please tell me what I'm missing here.
Thanks in advance.
The following are the VB code:-
Option Compare Database
Option Explicit
Public Function Replace(ByVal [qry_FPNamesMismatch]![NAME]
as field,ByVal _
" " as String,ByVal "" as String) As String
Dim Temp As String, P As Long
Temp = [qry_FPNamesMismatch]![NAME]
P = InStr(Temp, " ")
Do While P > 0
Temp = Left(Temp, P - 1) & "" & Mid(Temp, P + Len(" "))
P = InStr(P + Len(""), Temp, " ", 1)
Looop
Replace = Temp
End Function
Private Sub cmd_ViewQry_FPNamesMismatch_Click()
Dim StDocName As String
StDocName = "qry_FPNamesMismatch"
DoCmd.OpenQuery StDocName, acViewPreview, acEdit
call Replace (ByVal [qry_FPNamesMismatch]![NAME]as
field,ByVal _
" " as String,ByVal "" as String) As String
End Sub