Underscore

NigelShaw

Registered User.
Local time
Today, 12:35
Joined
Jan 11, 2008
Messages
1,575
Hi,

just a quickie......

when i save a folder name like Nigel_Shaw as a string in my route, the return value is always Nigel Shaw without the underscore.

how can i retain this underscore in the string?


many thanks guys



Nidge
 
have you tried using the ASCII code?
 
Hi Wik,

i havent because the file name is preset. i collect the name with vba and the file could be NigelShaw or Nigel-Shaw or Nigel_Shaw. i would have to check for characters along the whole string is it is not set within the Access environment


regs

nidge
 
i cant understand why you would lose the character. these are legal characters in file names. what are you actually seeing?
 
Hi GTH

I tried a different approach and set my code to collect a form name and store that name in a variable. My form was called frmTest_Form. The result I received was frmTest Form.

My error occurred when trying to open the form. I was trying to open frmTest_Form and as the variable was holding the other option, they didn't match thus failing.


Nidge
 
what code are you using to get the forn name then?
 
Hi

I'll post my code later when I get a chance. I get a collection of names and put them in a list.

Nidge
 
Nigel,

VBA really does not want to deal with objects that have a space in
their names.

For instance use a control like [My Button].

VBA can NOT use [My Button]_Click() for the event name. <-- No Brackets allowed.
VBA can NOT use My Button_Click() for the event name. <-- No Spaces allowed.

So VBA will "lend" your control name an underscore:

My_Button_Click()

It is therefore not possible for a form to have both of
these objects --> [My Button] and [My_Button] as they
both have the same name.

This is one of the reasons that I really try to avoid using
spaces and special symbols in names.

Wayne
 
Hi Wayne

I think you might have misunderstood.

My form is called frm_MyForm

the vba collects the name and the return value I get back is frm MyForm without the underscore.

I never have spaces in names


Nigel
 
Hi Wayne

I think you might have misunderstood.

My form is called frm_MyForm

the vba collects the name and the return value I get back is frm MyForm without the underscore.

I never have spaces in names


Nigel

Nigel, What Wayne was saying that neither spaces NOR SPECIAL CHARACTERS are good in names.

wayne said:
This is one of the reasons that I really try to avoid using
spaces and special symbols in names.
 
Hi,

thanks for the responses. i am not actually naming my forms with the underscore as my original query was regarding the collection of a folder name. i changed it to a form for the sake of keeping things local to the db. my thought was collecting a folder name as a string should collect ALL data as it is a string. when i made an example using a form name, i was hoping to get a different result but i didnt.

so, the collection of the form name was merely to duplicate the collection of the folder name.

when folders are created, no one takes into consideration the possibility of a Vba collecting the name and Vba not liking special characters.

the question is, can the underscore be identified in the name string and a message thrown out?


regs


nidge
 
I really think it's something to do with the specific code you've implemented because this is not normal behavior. To help us help you, we'd really need to see the original code that's stripping out the underscore.
 
Hi,

OK, so i finally get a change to open my project, get the code to show you and immediately see the reason why im getting the error- highlighted in RED!


Code:
ReDim arrForms(1 To 1)
        For Each varForms In db.Containers("Forms").Documents
            lngForms = lngForms + 1
            ReDim Preserve arrForms(1 To lngForms)
            arrForms(lngForms) = Replace(varForms.Name, [COLOR="Red"]"_", " "[/COLOR])
        Next varForms

so my code is replacing the underscore with a space! damn it.........


thanks though, it sometimes take a group of people to make you see your own mistakes


Nidge
 
phew! and here i thought i'd have to go through all my databases editing out my underscores!!
 
FWIW, underscore are one of very few characters (only one?) that can be reliably used in naming objects.

I personally don't like it (out of place relative to the shift key for the CamelCase convention), but it'd be the last factor in questions of whether special characters can case trouble.

The only exception to that is that you can't prefix the name with a underscore, though it is common in several programming languages as a mean to "hide" the functionalities. In fact, if you browse in Object Browser with Hidden Members visible, you're bound to find few objects with a underscore prefix!
 

Users who are viewing this thread

Back
Top Bottom