Referencing a Column with a Space in VBA (2 Viewers)

Pat Hartman

Super Moderator
Staff member
Local time
Today, 09:44
Joined
Feb 19, 2002
Messages
42,981
You're discovering the effects of the bad practice of using special characters or embedded spaces.

Just FYI, when you create a control with embedded spaces or special characters in its name, Access substitutes underscores for the offending characters. You renamed the control to remove the offending characters so you didn't see what Access does internally. Create a new control by dragging the field from the RecordSource. Access will name it Certificate_Number. You can see the name is "Cert Num" but in code, intellisense gives you Me.Cert_Num. Play around. see what happens when you create two fields -- "Cert Num" and "Cert-Num". Given that "-" is also an illegal character, what does Access do? I'm not telling you. Check yourself.

EmbeddedSpaces.JPG
 

Users who are viewing this thread

Top Bottom