Solved

Replace characters from Word form fields

Posted on 2003-11-13
3
420 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

947 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now