PDA

Click to See Complete Forum and Search --> : Selecting Certain Letters From a Table In Access


taosd
Sep 4th, 2003, 09:56 AM
Hi!
I am using access and my table has a set of data that is in the format 12-34-56 and I have a form which looks this information up. I was wondering if it were possible to have one field on a form that will display the first two numbers (12) and then in a second field display the rest of the numbers but remove the hyphen, all while keeping the data the same on the table. So the back end remains 12-34-56 but the first field displays 12 and the second field displays 3456

any ideas?!

Ephesians
Sep 15th, 2003, 03:46 PM
just use left$ and mid$ respectively.

zak2zak
Sep 17th, 2003, 12:25 PM
May be this helps...

TheData = "12-34-56"
TheData = Replace(TheData, "-", "", 1, , vbTextCompare)
Text1.Text = Mid$(TheData, 1, 2) ' 12
Text2.Text = Mid$(TheData, 3) ' 3456

Ephesians
Sep 17th, 2003, 12:40 PM
Word of caution.. if you're not using Access 2000 and above the Replace function will not be available to you.

taosd
Sep 17th, 2003, 12:45 PM
This was my solution, in the control source...


=Replace(Right$(sfrmOHMAll.Form!ATA,Len(sfrmOHMAll.Form!ATA)-3),'-','')

thanks all!