save Records
hey,
I use MS Access 2000 as backend. The problem is when I save record , it save the field with 2 blank spaces.
i.e when i browse my directory it says :
Username : Twinks
Password: twinks and 2 boxes on my VB form.
How do i rectify this error...!
I tried trim() when i save a record
thanx,
twinkle
[350 byte] By [
Twinkle] at [2007-11-18 2:13:25]

# 1 Re: save Records
The "2 boxes" you write about may be the vbNewLine symbols. Check if this is the problem by msgbox like:
MsgBox "[" & txtPassword.Text & "]"
If I'm right the output will be like that:
[twinks
]
And if so then try this:
txtPassword.Text = left(txtPassword.Text,InStr(txtPassword.Text,vbNewLine)-1)
or
while right(txtPassword.Text,1)=vbNewLine
txtPassword.Text=left(txtPassword.Text,Len(txtPassword.Text)-1)
If you want me to explain this code just ask me.
nikidd at 2007-11-10 0:02:35 >

# 4 Re: save Records
Yes the following line will delete the last char no matter what is it:
txtPassword.Text = left(txtPassword.Text,InStr(txtPassword.Text,vbNewLine)-1)
but using my second example with "while" will delete only CR LF chars at the end of string if any.
The first example can even result in error if they are not any CR LF chars in the string, or will make an unexpected result if the CR LF char is not at the end of it. So if you want to use it (I don't suggest you to do that because that was an example for test only) you must first check if they are any CR LF in the string and may be replace the InStr with InStrRev in order to get the last CR LF char (but even doing this it is no guarantie that it is at the end of string).
I hope my explain (sorry for my poor writen English) will help you understand what I had mean yestarday.
nikidd at 2007-11-10 0:05:34 >

# 5 Re: save Records
Sorry but my first sentence was not corect.
txtPassword.Text = left(txtPassword.Text,InStr(txtPassword.Text,vbNewLine)-1)
this will cut the text just before the first occurence of vbNewLine (CR LF) and if no CR LF in the text it will result in error.
Sorry but i just woke up and can't think so fast :D
nikidd at 2007-11-10 0:06:44 >
