Novice seeking help...suppress hyphens

B

bradjensmith

I have an easy vb question in MS Access. I'm looking to modify an
account number field that may contain hyphens. Forgive my "ugly"
code...

Currently I read in the field from the table and write it directly back
out.

Here's the SQL that pulls the data (including the Account_num field):

DIR_DEP_DISTRIB_tbl = "SELECT [DIRDEPDIST].*,DATASRCE_ID.US_CAN_IND " +
_
"FROM DIRDEPDIST INNER JOIN DATASRCE_ID ON
DIRDEPDIST.EMPLID = DATASRCE_ID.EMPLID " + _
"WHERE (((DATASRCE_ID.US_CAN_IND)='USA')); "

and then later I'm currently outputting like this to a text file:

Print #1, Tab(1); _
in_recs.Fields("EMPLID").Value & "|" & _
IIf(IsNull(in_recs.Fields("EFFDT").Value), "01JAN1900",
Format(CDate(in_recs.Fields("EFFDT").Value), "ddmmmyyyy")) & "|" & _
in_recs.Fields("PRIORITY").Value & "|" & _
in_recs.Fields("ACCOUNT_NUM").Value & "|" & _
in_recs.Fields("ACCOUNT_TYPE").Value & "|" & _
in_recs.Fields("BANK_CD").Value & "|" & _
in_recs.Fields("DEPOSIT_AMT").Value & "|" & _
in_recs.Fields("AMOUNT_PCT").Value & "|" & _
IIf(in_recs.Fields("DEPOSIT_TYPE").Value = "B", "Y", " ") & "|" & _
Format(Date, "ddmmmyyyy") & "|INITLOAD|" & _
Format(Date, "ddmmmyyyy") & "|INITLOAD";


The ACCOUNT_NUM field is the field I need to modify to suppress hyphens
if they appear.

Thanks for any help!!
 
H

hippomedon

Have you tried using the Replace function?
Replace(in_recs.Fields("ACCOUNT_NUM").Value,"-","")

It might do the trick.
Paul
 
B

bradjensmith

Thanks Paul...Just stumbled upon this....Assigned a new variable
ACCOUNT and did this:

ACCOUNT = Replace(in_recs.Fields("ACCOUNT_NUM"), "-", "")

Just to confirm, it appears that if the field doesn't contain "-" it
still outputs correctly.

Thanks for the help!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top