rajasachin
asked on
Replace function not working in Access
I dont want some of my fields to contain characters like [ * ;
Hence I am using 'replace' function in access database query to remove those characters.
I was successful in writing the same and it worked.
But since now I have changed my PC the same query is not working.
I have windows 2000 server as OS and VB6 and VS.net installed on my new machine.
I found on microsoft site that this is due to having vbajet32.dll with version 5.0 or more installed on my machine and I need to have vbajet32.dll with version 3.0.0.6098 (which I was unable to find anywhere) It has been mentioned that this version ships with MDAC 1.5 and I have installed MDAC 2.8
The mdac 1.5 is no longer available on any site.
I guess MDAC 1.5 may be coming with IE 4 or Win98 but not sure.
Please help. I want the query to run anyhow from my machine only.
Hence I am using 'replace' function in access database query to remove those characters.
I was successful in writing the same and it worked.
But since now I have changed my PC the same query is not working.
I have windows 2000 server as OS and VB6 and VS.net installed on my new machine.
I found on microsoft site that this is due to having vbajet32.dll with version 5.0 or more installed on my machine and I need to have vbajet32.dll with version 3.0.0.6098 (which I was unable to find anywhere) It has been mentioned that this version ships with MDAC 1.5 and I have installed MDAC 2.8
The mdac 1.5 is no longer available on any site.
I guess MDAC 1.5 may be coming with IE 4 or Win98 but not sure.
Please help. I want the query to run anyhow from my machine only.
This response will be of no help to you but I'm just clarifying the situation.
From the wording of your Q I am assuming that you have a vb6 application which is using a Jet (Access, if you like) database.
If you are referring to this article:
http://support.microsoft.com/default.aspx?scid=kb;en-us;189448
then it clearly states that the problem is resolved in VB6.
It also indicates that the problem is not specific to the Replace function but applies to all functions and that it is the use of functions which is the problem, not the use of special characters.
Pete
From the wording of your Q I am assuming that you have a vb6 application which is using a Jet (Access, if you like) database.
If you are referring to this article:
http://support.microsoft.com/default.aspx?scid=kb;en-us;189448
then it clearly states that the problem is resolved in VB6.
It also indicates that the problem is not specific to the Replace function but applies to all functions and that it is the use of functions which is the problem, not the use of special characters.
Pete
ASKER
Dear harfang
One of my query is like this,
UPDATE Chemistlist SET Address2 = replace(replace(replace(re place(repl ace(replac e(replace( replace(re place(repl ace(replac e(replace( replace(re place(repl ace([Addre ss2],"-"," "),"("," "),")"," "),"."," "),"`"," "),"'"," "),"*"," "),"["," "),"]"," "),","," "),"#"," "),"'"," "),"$"," "),'"'," "),"®"," ");
and I have nearly 25 similar queries.
The way you told me to change the queries will take a lot of time.
Can u suggest some shortcut
Sachin
One of my query is like this,
UPDATE Chemistlist SET Address2 = replace(replace(replace(re
and I have nearly 25 similar queries.
The way you told me to change the queries will take a lot of time.
Can u suggest some shortcut
Sachin
You will need a custom VB function. There are several ways to do this, of course. The following is one I used to create file names from various string keys. (One client *did* in fact have a function key "CON" and "con.html" is a very bad name for writing to :)
''CleanName function''
'
' Converts a string from the standard ascii table (commented) to a simplified
' 7-bit table with all "dangerous" characters removed and in lower case.
'
Function CleanName(ByVal pstrName As String) As String
' "_________________________ _______ !"#$%&'()*+,-./0123456789: ;<=>?"
' "@ABCDEFGHIJKLMNOPQRSTUVWX YZ[\]^_`ab cdefghijkl mnopqrstuv wxyz{|}~"
' "€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜ ™š›œžŸ ¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º »¼½¾¿"
' "ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×Ø ÙÚÛÜÝÞßàáâ ãäåæçèéêëì íîïðñòóôõö ÷øùúûüýþÿ"
' just clean:
'Const cClean As String _
= "_________________________ __________ _S_-_()___ -__0123456 789______" _
& "_ABCDEFGHIJKLMNOPQRSTUVWX YZ(_)___ab cdefghijkl mnopqrstuv wxyz(_)-_" _
& "E__f______S_O_________--- _s_o__Y__c LxY-S_Ca_( -R-o-23-mP __10)____" _
& "AAAAAAACEEEEIIIIDNOOOOOxO UUUUY_saaa aaaaceeeei iii_nooooo -ouuuuy_y"
' also lcase:
Const cClean As String _
= "_________________________ __________ _s_-_()___ -__0123456 789______" _
& "_abcdefghijklmnopqrstuvwx yz(_)___ab cdefghijkl mnopqrstuv wxyz(_)-_" _
& "e__f______s_o_________--- _s_o__y__c lxy-y_ca_( -r-o-23-mp __10)____" _
& "aaaaaaaceeeeiiiidnoooooxo uuuuy_saaa aaaaceeeei iii_nooooo -ouuuuy_y"
Dim strClean As String
Dim intPos As Integer
' Convert all chars:
For intPos = 1 To Len(pstrName)
strClean = strClean _
& Mid$(cClean, Asc(Mid$(pstrName, intPos, 1)) + 1, 1)
Next intPos
' MS-DOS won't like those very much...
Select Case UCase$(strClean)
Case "CON", "NUL" _
, "LPT1", "LPT2", "LPT3", "LPT4" _
, "COM1", "COM2", "COM3", "COM4"
strClean = strClean & "_"
End Select
CleanName = strClean
End Function
''CleanName function''
'
' Converts a string from the standard ascii table (commented) to a simplified
' 7-bit table with all "dangerous" characters removed and in lower case.
'
Function CleanName(ByVal pstrName As String) As String
' "_________________________
' "@ABCDEFGHIJKLMNOPQRSTUVWX
' "€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜
' "ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×Ø
' just clean:
'Const cClean As String _
= "_________________________
& "_ABCDEFGHIJKLMNOPQRSTUVWX
& "E__f______S_O_________---
& "AAAAAAACEEEEIIIIDNOOOOOxO
' also lcase:
Const cClean As String _
= "_________________________
& "_abcdefghijklmnopqrstuvwx
& "e__f______s_o_________---
& "aaaaaaaceeeeiiiidnoooooxo
Dim strClean As String
Dim intPos As Integer
' Convert all chars:
For intPos = 1 To Len(pstrName)
strClean = strClean _
& Mid$(cClean, Asc(Mid$(pstrName, intPos, 1)) + 1, 1)
Next intPos
' MS-DOS won't like those very much...
Select Case UCase$(strClean)
Case "CON", "NUL" _
, "LPT1", "LPT2", "LPT3", "LPT4" _
, "COM1", "COM2", "COM3", "COM4"
strClean = strClean & "_"
End Select
CleanName = strClean
End Function
ASKER
I really appreciate your efforts to help me out. I am really amazed to see the kind of help EE is offering.
Thanks a lott Dear "harfang",
I will just try this solution right now.
Thanks a lott Dear "harfang",
I will just try this solution right now.
Before you loose any time: in VB, open "Tools / References". If one of them is marked as MISSING, this could be the cause of the problem. Of course I still suggest a custom replace function in your case :)
Cheers
Cheers
ASKER
The Clean Name function is not working instead it corrupted my data.
Dont Mind I had taken backup before using that.
Its really "dangerous" yaar.
But cant the system be corrected to use the existing function.
Dont Mind I had taken backup before using that.
Its really "dangerous" yaar.
But cant the system be corrected to use the existing function.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Join(Split(pstrString,";")
for
Replace(pstrString, ";", "")
cheers!