Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

compile error when using % character as column name

Status
Not open for further replies.

lauerj

Technical User
May 15, 2003
14
US
The vb code powering one of my forms is giving me a compile error due to my use of the '%' character in the following statement:

fsubQtrDemand.Controls("textnp" + strTag).Value = rst!%_hr_peak

However '%_hr_peak' is the name of the column that I need to read from...is there a easy syntax change I need to make in order to get the code to compile? Any other solutions?
 
It's an application I inherited and was hired to fix!
 
Alright, I was able to solve my problem by using an alias in my SQL query (returning the %_hr_peak field AS PercentHourPeak). Binding the expression inside [] usually works as well but was not in this case I think because it was a calculated expression.

A number of fields in this db do not make sense. Does it matter if there are spaces in the table names or field names?
 
No, it doesn't matter. However, in such cases you need to bracket the name: [Field Name]

It's highly recommendable to avoid spaces and special characters, but since you've inherited the application I don't think you can strip them...

HTH


[pipe]
Daniel Vlas
Systems Consultant

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top