Solved

Replace characters from Word form fields

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
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…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

733 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