Solved

Replace characters from Word form fields

Posted on 2003-11-13
3
416 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
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…

743 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

15 Experts available now in Live!

Get 1:1 Help Now