Re: [問題] Excel VBA 連結 Access 查詢有錯??
: strsql = "SELECT * from testdata where text='" & InputBox("Text") & "'"
: 在資料庫內我有先增加幾筆資料 text 欄位中的 C9B123,C5B555,D85BB,K1235
: 我在跳出的輸入視窗中輸入 C9 ,但是這樣卻沒有查詢到資料??
: 是不是我查詢那一欄位寫法有問題??
: 我希望能做到模糊查詢
where text like 'C9%'
: 就是只輸入 C9B 甚至 C 這樣查詢條件
: 就可以將資料庫 text 欄位中有 C9B 或 C 開頭的都能顯示出來
: 除此外~~
: 假設如果我要將某範圍欄位(ex:B1~B25)寫入資料庫內
RecordSet.Addnew 欄位名稱,欄位內容
RecordSet.Update
: 要怎樣全部批次寫入資料庫,
: 這程式碼要怎樣寫~~
ColumnsArray = Array("欄位名稱1","欄位名稱2")
For rowPos = 1 To 25
val1 = Cells(rowPos,1).value
val2 = Cells(rowPos,2).value
ColumnsValue = Array(val1,val2)
RecordSet.Addnew ColumnsArray,ColumnsValue
Next
RecordSet.Update
控制項TextBox內容 Text屬性內容要強迫為大寫字母
在KeyPress事件判斷
KeyAscii.Value為使用者按下鍵的ASCII Code
A = 65 B = 66 ... Z = 90
a = 97 b = 98 ... z = 122
Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If (KeyAscii.Value >= 97) And (KeyAscii.Value <= 122) Then
'使用者輸入小寫字母
'將輸入鍵的ASCII 扣除32 轉換成大寫字母
KeyAscii.Value = KeyAscii.Value - 32
End If
End Sub
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 218.167.60.195
※ 編輯: Steven0422 來自: 218.167.60.195 (01/30 18:57)
※ 編輯: Steven0422 來自: 218.167.60.195 (01/30 19:54)
※ 編輯: Steven0422 來自: 218.167.60.195 (01/30 20:09)
討論串 (同標題文章)
Office 近期熱門文章
PTT數位生活區 即時熱門文章