Discussion Locked

Visual Basic

0 helpful
9 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

How to insert comma in a database field by default throuhg a VB Text Box. Example:
1,2,3,5 or
a,b,c,g like this...... for a memo field in access.

9 replies

by sdbytnar

Do you have any code samples that you have tried but that did not work? Have you tried simply setting the database value to the value of the text property of the textbox?

Sean

by lord ago 1

Simple string manipulation will do. In this case it's a little more difficult due to the field being a memo. The idea is to break down the memo field by looking for spaces between the words. Then, it's just simply concactanating the "," to the end of the word up until the last word is reached. Use something like:
set "x" variable to be a variant. Quick way is to not declare it and just use it.

Then have it hold the memo.

Next, look for the spaces. If one is found and there IS more afterit (hint length(x)) then insert the comma in place of the space without removing the space. If nothing is left after the space or there is no more spaces then you already have the end of the memo.

use the INSTR function to gain and hold the place of spaces within the memo and you can use that to know where to put the commas.
Using the MID function will also come in REAL handy for this.

Have Fun!!

by peyison

If you're using VB 6, you can use the following code:

Text1 = Replace(Text1, " ", ",")

This will replace every space (" ") with a comma (",").

Hope this helps.

by rsv

Hi,
Before inserting in the MS Access database, manuplate the memo field value. For example, you r inserting the data which is in the "txtMemo" textbox, before inserting in the MS Access, write this code....

txtMemo.text=Replace(txtMemo.text, " ", "'",,,vbTextCompare)

This function will replaces the spaces with comma (,) in the txtMemo field.

Hope this helps you.
GOOD LUCK...:)

This discussion is closed to new replies.