PC Review


Reply
Thread Tools Rate Thread

coding question - numbers

 
 
alex
Guest
Posts: n/a
 
      1st Jun 2007
I'm trying to write some code that locks several controls on a form...
Some of the names of the controls are numbers or have numbers in the
name.
I'm getting an error in VBA at run time, related to these numbers.
Do I have to change the names of the controls, or is there a work-
around?

thanks,
alex

 
Reply With Quote
 
 
 
 
Allen Browne
Guest
Posts: n/a
 
      1st Jun 2007
Enclose the name in square brackets.

For example,if the text box is named 5, use:
Me.[5].Locked = False

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"alex" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I'm trying to write some code that locks several controls on a form...
> Some of the names of the controls are numbers or have numbers in the
> name.
> I'm getting an error in VBA at run time, related to these numbers.
> Do I have to change the names of the controls, or is there a work-
> around?
>
> thanks,
> alex
>

 
Reply With Quote
 
alex
Guest
Posts: n/a
 
      1st Jun 2007
On Jun 1, 10:51 am, "Allen Browne" <AllenBro...@SeeSig.Invalid> wrote:
> Enclose the name in square brackets.
>
> For example,if the text box is named 5, use:
> Me.[5].Locked = False
>
> --
> Allen Browne - Microsoft MVP. Perth, Western Australia
> Tips for Access users -http://allenbrowne.com/tips.html
> Reply to group, rather than allenbrowne at mvps dot org.
>
> "alex" <sql_...@yahoo.com> wrote in message
>
> news:(E-Mail Removed)...
>
>
>
> > I'm trying to write some code that locks several controls on a form...
> > Some of the names of the controls are numbers or have numbers in the
> > name.
> > I'm getting an error in VBA at run time, related to these numbers.
> > Do I have to change the names of the controls, or is there a work-
> > around?

>
> > thanks,
> > alex- Hide quoted text -

>
> - Show quoted text -


Thanks Allen.

I also have a bound control named, e.g., Number_5.
Is there a special case for this? I tried putting the whole name and/
or the number in brackets...to no avail

alex

 
Reply With Quote
 
BruceM
Guest
Posts: n/a
 
      1st Jun 2007

"alex" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> On Jun 1, 10:51 am, "Allen Browne" <AllenBro...@SeeSig.Invalid> wrote:
>> Enclose the name in square brackets.
>>
>> For example,if the text box is named 5, use:
>> Me.[5].Locked = False
>>
>> --
>> Allen Browne - Microsoft MVP. Perth, Western Australia
>> Tips for Access users -http://allenbrowne.com/tips.html
>> Reply to group, rather than allenbrowne at mvps dot org.
>>
>> "alex" <sql_...@yahoo.com> wrote in message
>>
>> news:(E-Mail Removed)...
>>
>>
>>
>> > I'm trying to write some code that locks several controls on a form...
>> > Some of the names of the controls are numbers or have numbers in the
>> > name.
>> > I'm getting an error in VBA at run time, related to these numbers.
>> > Do I have to change the names of the controls, or is there a work-
>> > around?

>>
>> > thanks,
>> > alex- Hide quoted text -

>>
>> - Show quoted text -

>
> Thanks Allen.
>
> I also have a bound control named, e.g., Number_5.
> Is there a special case for this? I tried putting the whole name and/
> or the number in brackets...to no avail
>
> alex
>


Rather than describing what you have done, it would be best to post the
actual code, including the event in which it occurs. Also, describe the
expected result, and what happens instead.


 
Reply With Quote
 
alex
Guest
Posts: n/a
 
      1st Jun 2007
On Jun 1, 12:57 pm, "BruceM" <bam...@yawhodotcalm.not> wrote:
> "alex" <sql_...@yahoo.com> wrote in message
>
> news:(E-Mail Removed)...
>
>
>
>
>
> > On Jun 1, 10:51 am, "Allen Browne" <AllenBro...@SeeSig.Invalid> wrote:
> >> Enclose the name in square brackets.

>
> >> For example,if the text box is named 5, use:
> >> Me.[5].Locked = False

>
> >> --
> >> Allen Browne - Microsoft MVP. Perth, Western Australia
> >> Tips for Access users -http://allenbrowne.com/tips.html
> >> Reply to group, rather than allenbrowne at mvps dot org.

>
> >> "alex" <sql_...@yahoo.com> wrote in message

>
> >>news:(E-Mail Removed)...

>
> >> > I'm trying to write some code that locks several controls on a form...
> >> > Some of the names of the controls are numbers or have numbers in the
> >> > name.
> >> > I'm getting an error in VBA at run time, related to these numbers.
> >> > Do I have to change the names of the controls, or is there a work-
> >> > around?

>
> >> > thanks,
> >> > alex- Hide quoted text -

>
> >> - Show quoted text -

>
> > Thanks Allen.

>
> > I also have a bound control named, e.g., Number_5.
> > Is there a special case for this? I tried putting the whole name and/
> > or the number in brackets...to no avail

>
> > alex

>
> Rather than describing what you have done, it would be best to post the
> actual code, including the event in which it occurs. Also, describe the
> expected result, and what happens instead.- Hide quoted text -
>
> - Show quoted text -


Ok Bruce,

Here's the code: 'Me!NUMBER_5.Locked = False
I expect it to unlock the control named number_5
Instead I get a run time error: Object doesn't support this method or
property

I have other controls that are named with just numbers and Allen's
advise works fine.
I'm having problems however with alpha/numeric controls like
'Number_5'; the brackets don't work.

alex

 
Reply With Quote
 
Allen Browne
Guest
Posts: n/a
 
      1st Jun 2007
If the error states that the object named number_5 does not have this
method, chances are that it is not a text box.

Perhaps the field in the form's RecordSource is named number_5, but the text
box bound to this field is named something else, such as Text8.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"alex" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> On Jun 1, 12:57 pm, "BruceM" <bam...@yawhodotcalm.not> wrote:
>> "alex" <sql_...@yahoo.com> wrote in message
>>
>> news:(E-Mail Removed)...
>>
>>
>>
>>
>>
>> > On Jun 1, 10:51 am, "Allen Browne" <AllenBro...@SeeSig.Invalid> wrote:
>> >> Enclose the name in square brackets.

>>
>> >> For example,if the text box is named 5, use:
>> >> Me.[5].Locked = False

>>
>> >> --
>> >> Allen Browne - Microsoft MVP. Perth, Western Australia
>> >> Tips for Access users -http://allenbrowne.com/tips.html
>> >> Reply to group, rather than allenbrowne at mvps dot org.

>>
>> >> "alex" <sql_...@yahoo.com> wrote in message

>>
>> >>news:(E-Mail Removed)...

>>
>> >> > I'm trying to write some code that locks several controls on a
>> >> > form...
>> >> > Some of the names of the controls are numbers or have numbers in the
>> >> > name.
>> >> > I'm getting an error in VBA at run time, related to these numbers.
>> >> > Do I have to change the names of the controls, or is there a work-
>> >> > around?

>>
>> >> > thanks,
>> >> > alex- Hide quoted text -

>>
>> >> - Show quoted text -

>>
>> > Thanks Allen.

>>
>> > I also have a bound control named, e.g., Number_5.
>> > Is there a special case for this? I tried putting the whole name and/
>> > or the number in brackets...to no avail

>>
>> > alex

>>
>> Rather than describing what you have done, it would be best to post the
>> actual code, including the event in which it occurs. Also, describe the
>> expected result, and what happens instead.- Hide quoted text -
>>
>> - Show quoted text -

>
> Ok Bruce,
>
> Here's the code: 'Me!NUMBER_5.Locked = False
> I expect it to unlock the control named number_5
> Instead I get a run time error: Object doesn't support this method or
> property
>
> I have other controls that are named with just numbers and Allen's
> advise works fine.
> I'm having problems however with alpha/numeric controls like
> 'Number_5'; the brackets don't work.
>
> alex


 
Reply With Quote
 
alex
Guest
Posts: n/a
 
      1st Jun 2007
On Jun 1, 1:15 pm, "Allen Browne" <AllenBro...@SeeSig.Invalid> wrote:
> If the error states that the object named number_5 does not have this
> method, chances are that it is not a text box.
>
> Perhaps the field in the form's RecordSource is named number_5, but the text
> box bound to this field is named something else, such as Text8.
>
> --
> Allen Browne - Microsoft MVP. Perth, Western Australia
> Tips for Access users -http://allenbrowne.com/tips.html
> Reply to group, rather than allenbrowne at mvps dot org.
>
> "alex" <sql_...@yahoo.com> wrote in message
>
> news:(E-Mail Removed)...
>
>
>
> > On Jun 1, 12:57 pm, "BruceM" <bam...@yawhodotcalm.not> wrote:
> >> "alex" <sql_...@yahoo.com> wrote in message

>
> >>news:(E-Mail Removed)...

>
> >> > On Jun 1, 10:51 am, "Allen Browne" <AllenBro...@SeeSig.Invalid> wrote:
> >> >> Enclose the name in square brackets.

>
> >> >> For example,if the text box is named 5, use:
> >> >> Me.[5].Locked = False

>
> >> >> --
> >> >> Allen Browne - Microsoft MVP. Perth, Western Australia
> >> >> Tips for Access users -http://allenbrowne.com/tips.html
> >> >> Reply to group, rather than allenbrowne at mvps dot org.

>
> >> >> "alex" <sql_...@yahoo.com> wrote in message

>
> >> >>news:(E-Mail Removed)...

>
> >> >> > I'm trying to write some code that locks several controls on a
> >> >> > form...
> >> >> > Some of the names of the controls are numbers or have numbers in the
> >> >> > name.
> >> >> > I'm getting an error in VBA at run time, related to these numbers.
> >> >> > Do I have to change the names of the controls, or is there a work-
> >> >> > around?

>
> >> >> > thanks,
> >> >> > alex- Hide quoted text -

>
> >> >> - Show quoted text -

>
> >> > Thanks Allen.

>
> >> > I also have a bound control named, e.g., Number_5.
> >> > Is there a special case for this? I tried putting the whole name and/
> >> > or the number in brackets...to no avail

>
> >> > alex

>
> >> Rather than describing what you have done, it would be best to post the
> >> actual code, including the event in which it occurs. Also, describe the
> >> expected result, and what happens instead.- Hide quoted text -

>
> >> - Show quoted text -

>
> > Ok Bruce,

>
> > Here's the code: 'Me!NUMBER_5.Locked = False
> > I expect it to unlock the control named number_5
> > Instead I get a run time error: Object doesn't support this method or
> > property

>
> > I have other controls that are named with just numbers and Allen's
> > advise works fine.
> > I'm having problems however with alpha/numeric controls like
> > 'Number_5'; the brackets don't work.

>
> > alex- Hide quoted text -

>
> - Show quoted text -


Thanks for your help Allen; I'll give it a try.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Color Coding Numbers Ben Microsoft Access 3 24th Apr 2009 04:12 PM
Coding letters and numbers =?Utf-8?B?TGluZHM=?= Microsoft Excel Misc 3 21st Dec 2005 07:57 PM
color coding numbers in excel Mackbeer Microsoft Excel Discussion 2 27th Jun 2005 07:12 PM
Coding for Random Numbers on a form =?Utf-8?B?SmVycnk=?= Microsoft Access Form Coding 1 20th Jul 2004 04:09 PM
Problems with coding and coding question!! James Microsoft Access Form Coding 0 23rd Feb 2004 10:34 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:36 AM.