Solved

Replace characters from Word form fields

Posted on 2003-11-13
3
423 Views
Last Modified: 2008-03-03
I'm importing data from some word form fields.  Some of the fields are blank, but I'm getting squares instead of characters for the field.  When I do an  ?Asc() on the squares, it says that they are # 32.  I tried doing the following replace:
strName = Replace(strName, Chr(32), "", 1, 8)
This didn't work, but it did remove the spaces from other text .  I also tried  Chr(10) , Chr(13), vbCr, vbLF, vbCrLF, and vbTab

The replace just doesn't seem to be working on these characters.
Any suggestions???
0
Comment
Question by:Mach1pro
  • 2
3 Comments
 
LVL 54

Accepted Solution

by:
nico5038 earned 125 total points
ID: 9741880
Hmm, then I would revert to using a simple loop like:

dim intI as integer
dim strResult as string

strResult = ""
for intI = 1 to len(formfield)
     if mid(formfield,intI,1) <> chr(32) then
         strResult = strResult & mid(formfield,intI,1)
     endif
next

Nic;o)
0
 
LVL 6

Author Comment

by:Mach1pro
ID: 9753520
Nico,
I did make a variation of your function, but instead used the Left  function.  That way it didn't remove the
spaces between words that should be there.  I still don't know why the Replace wouldn't work in this case
I know I have used it in similar instances in the past
0
 
LVL 54

Expert Comment

by:nico5038
ID: 9753533
Hi,

Instead if the Left you could also use:
     if mid(formfield,intI,1) <> chr(32) then
         strResult = strResult & mid(formfield,intI,1)
      else
         strResult = strResult & " "
     endif
to get the space :-)

The no working Replace also puzzles me as your
 Replace(strName, Chr(32), "", 1, 8)
certainly should work.

BTW you're not having troubles with the references of the database ?
(Open tools/references when looking to some VBA and check for "MISSING" in the checked library references)

Nic;o)
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question