其他人已經得到了部分內容,但我認爲沒有人得到這一切正確。它應該是這樣的:
strLocalSql = "SELECT tblEventTypeList.EventType" & _
" FROM tblEventTypeList" & _
" WHERE tblEventTypeList.[EventPage] = " & ts & _
" ORDER BY tblEventTypeList.[EventType];"
這假定您的EvenPage字段是數字(並且ts變量中的值是數字)。如果是文本,那麼你需要這個,而是:
strLocalSql = "SELECT tblEventTypeList.EventType" & _
" FROM tblEventTypeList" & _
" WHERE tblEventTypeList.[EventPage] = " _
& Chr(34) & ts & Chr(34) & _
" ORDER BY tblEventTypeList.[EventType];"
就個人而言,我在我所有的Access項目保持恆定的定義這樣的:
Global Const STR_QUOTE As String = """"
...然後我使用常數串聯。不過,我希望我已經命名爲strQ,因爲名字太長了。但我已經使用了十多年了,所以我很難改變!這會工作:
Global Const strQ As String = """"
strLocalSql = "SELECT tblEventTypeList.EventType" & _
" FROM tblEventTypeList" & _
" WHERE tblEventTypeList.[EventPage] = " _
& strQ & ts & strQ & _
" ORDER BY tblEventTypeList.[EventType];"
...但當然,這是唯一正確的,如果EvenPage是一個字符串。
以及FROM ... – hawbsl 2010-10-11 14:53:58