Need some help with Left (string,number) command

D

Darhl Thomason

I'm familiar with the Left (and Right and Mid) commands, but my brain
evidently isn't firing on all cylinders today. My code is inside an
On_Click event for a command button and the value is returning the same as
the main string. txtNumber is bound to Number which is always a 5 character
field (set as primary key), but when I use this code, strTemp results in the
same text as Me.txtNumber.

strTemp = Left(Me.txtNumber, 2)

I have it working properly on a report where the control source of a text
box is

Left([Number],2)

Thanks!

Darhl
 
F

fredg

I'm familiar with the Left (and Right and Mid) commands, but my brain
evidently isn't firing on all cylinders today. My code is inside an
On_Click event for a command button and the value is returning the same as
the main string. txtNumber is bound to Number which is always a 5 character
field (set as primary key), but when I use this code, strTemp results in the
same text as Me.txtNumber.

strTemp = Left(Me.txtNumber, 2)

I have it working properly on a report where the control source of a text
box is

Left([Number],2)

Thanks!

Darhl

Perhaps it's because txtNumber is getting it's data from your field
named [Number]. Whether that is the problem or not, it would be wise
to change that field name to something else.

Number is a reserved Access/VBA/Jet word and should not be used as a
field name.
For additional reserved words, see the Microsoft KnowledgeBase article
for your version of Access:

109312 'Reserved Words in Microsoft Access' for Access 97
209187 'ACC2000: Reserved Words in Microsoft Access'
286335 'ACC2002: Reserved Words in Microsoft Access'
321266 'ACC2002: Microsoft Jet 4.0 Reserved Words'
 
D

Darhl Thomason

Thanks for the suggestion Fred. I will check those articles you pointed
out. I didn't realize that "Number" was a reserved name. I will fix that.

On another note, the code does work, I have it in two places and only
updated one. Of course I was only looking at the one that wasn't updating
:) (aka big sheepish grin).

Darhl


fredg said:
I'm familiar with the Left (and Right and Mid) commands, but my brain
evidently isn't firing on all cylinders today. My code is inside an
On_Click event for a command button and the value is returning the same
as
the main string. txtNumber is bound to Number which is always a 5
character
field (set as primary key), but when I use this code, strTemp results in
the
same text as Me.txtNumber.

strTemp = Left(Me.txtNumber, 2)

I have it working properly on a report where the control source of a text
box is

Left([Number],2)

Thanks!

Darhl

Perhaps it's because txtNumber is getting it's data from your field
named [Number]. Whether that is the problem or not, it would be wise
to change that field name to something else.

Number is a reserved Access/VBA/Jet word and should not be used as a
field name.
For additional reserved words, see the Microsoft KnowledgeBase article
for your version of Access:

109312 'Reserved Words in Microsoft Access' for Access 97
209187 'ACC2000: Reserved Words in Microsoft Access'
286335 'ACC2002: Reserved Words in Microsoft Access'
321266 'ACC2002: Microsoft Jet 4.0 Reserved Words'
 
F

fredg

Thanks for the suggestion Fred. I will check those articles you pointed
out. I didn't realize that "Number" was a reserved name. I will fix that.

On another note, the code does work, I have it in two places and only
updated one. Of course I was only looking at the one that wasn't updating
:) (aka big sheepish grin).

Darhl

Ah I know that feeling!
 

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