Automated Caps in code?

virtualpete

Registered User.
Local time
Yesterday, 21:46
Joined
Aug 25, 2010
Messages
21
Hi, I am having a few issues with my module code in Access 2002. for some reason every time I write some code Access is automatically making the first letter a capital so for instance [Our Ref] should be [Our ref] but it simply will not let me do it!

Temp = rstHTML!html1 & rstProp![Our Ref] & rstHTML!html2 & rstProp![Our Ref] & rstHTML!html3 & rstProp![Property Title]

Has anyone experienced this before or any ideas what I can do?

I look forward to hearing from you.
 
If you declared the variable in a Dim statement it will auto-correct the case to match.

So Dim [Our ref] as string

will force all instances in the code to [Our ref]. Change the dim statement and your code will all change.
 
I assume [Our Ref] IS capitalised in that way in your table.

Access seems to verify that the field exists (although it does not object if it doesn't - just crashes at run time) - and gives you the same case as the field in the table.

I find it a useful feature for verifying I have typed fieldnames correctly

Why is it a problem in code, anyway?
 
Thanks Guys, I have tried to add it to the variable like so:
'Declare variables
Dim db As Database ' Database
Dim rstHTML As Recordset ' HTML table recordset
Dim rstProp As Recordset ' Property table recordset
Dim rstPrice As Recordset ' Price table recordset
Dim rstTest As Recordset ' Testimonials table recordset
Dim rstWebLink As Recordset ' Website link table recordset
Dim SQLstat As String ' SQL statement
Dim strHTMLTemplate As String ' HTML template name
Dim strHTMLFile As String ' HTML output file name
Dim intFileIn As Integer ' File number of input file
Dim intFileOut As Integer ' File number of output file
Dim blnLine As Boolean
Dim [Our ref] As String

But I get an error message Expected:identifier ?

In my Table the field name is Our ref
 
I don't think you should Dim it.

Maybe access automatically capitalises Ref. It does treat some words like ID and Code as special cases - eg it automatically creates indexes for fields ending in either of those.

(see the autoindex option in tools-options-tables/queries)

It really shouldn't be a problem, assuming it works
 
In my Table the field name is Our ref

In that case ignore my Dim comment. I think Dave is on the right track that Ref is treated as a "special" field name in Access.

TBH access isn't case sensitive for this type of code, but if it's really bothering you I would either remove the space from the field name (Possibly a headache but good practice) or ignore it.
 
Similar to what Minty advised but you actually:
1. Dim ref As String
2. Move your cursor to another code line and it will go back to normal, then you can delete the Dim.

Field names should not affect code definitions and I can't find any reference to ref in the library so it must be user-defined.
 

Users who are viewing this thread

Back
Top Bottom