[RESOLVED] what to do if table head contains bracket
I have a table with one field name "Time (Date + Hour)". Now when I write the code
Code:
strSQL = "SELECT [Time (Date + Hour)] FROM tblName"
rs.CursorLocation = adUseClient
rs.Open strSQL, con, adOpenDynamic, adLockOptimistic
MsgBox rs(Time (Date + Hour))
It shows error code. How can I read the value then?
Re: what to do if table head contains bracket
SELECT `Time (Date + Hour)` FROM tblName
Does this work? Or is the problem with the msgbox?
You can always rename the name of the field returned to not contain spaces or brackets.
SELECT [Time (Date + Hour)] AS Time FROM tblName
something like that...
Re: what to do if table head contains bracket
I dont have any problem with SQL. It works fine. But when i want to get values from recordset, Like rs(Time (Date + Hour)), then the problem arises.
And, I can't change the field name, because of some regulation.
Re: what to do if table head contains bracket
The first line
strSQL = "SELECT [Time (Date + Hour)] FROM tblName"
is Ok.
The problem is in line
MsgBox rs(Time (Date + Hour))
It should be:
MsgBox rs![Time (Date + Hour)]
or
MsgBox rs("Time (Date + Hour)")
Re: what to do if table head contains bracket
thanx a lot .. So fool of me! .. I should try that before.. Now I'll try
Re: [RESOLVED] what to do if table head contains bracket
But it
Code:
MsgBox rs![Time (Date + Hour)]
does not work !!!!!!!!!!!!
Re: [RESOLVED] what to do if table head contains bracket
Try to learn the syntax yourself and you will know what you have to do when the field name contains spaces and orther non-alphanumeric character.
Re: [RESOLVED] what to do if table head contains bracket
sorry pal, thought that as I had the opportunity to ask the vb wizards, it may save my time, becoz I am new and really in hurry. Anyway, thanx 4 all ur help. Btw, my problem is solved.