Solved

Replace characters from Word form fields

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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
trouble referencing field on sub form 8 37
ADODB problem 20 38
IIF in access query 19 26
Calculated field not displaying as currency on form 4 20
When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

831 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