what is wrong with this code? very simple one

  • Thread starter Thread starter ma
  • Start date Start date
M

ma

Hello,
This simple code doesn't work for me. Why?

dim s as string
if isnull(UserName_Input) then
s=""
else
s= UserName_input.Text
end if

UserName_input is a text input field on the form.

what is the problem?

best regards
 
ma said:
Hello,
This simple code doesn't work for me. Why?

dim s as string
if isnull(UserName_Input) then
s=""
else
s= UserName_input.Text
end if

UserName_input is a text input field on the form.

what is the problem?

You don't say what error message you get, if any, when you execute the
code. That always helps. However, one possible problem is that you can
only refer to the Text property of a control when the control has the
focus. Access is different from VB in that respect. Most of the time,
you want to use the Value property of the control, which is the default
property and is available at all times.

Try revising your code as follows:

dim s as string

if isnull(Me!UserName_Input) then
s=""
else
s= Me!UserName_input
end if

The "Me!" qualifier is not always necessary, and probably isn't in this
case, but it's a good habit to get into.
 
Back
Top