Sub 查找()
Set conn = CreateObject("adodb.connection")
Set Rst = CreateObject("ADODB.recordset")
conn.Open
"Provider=Microsoft.ACE.OLEDB.12.0;Data Source="
& "D:/Database.accdb" ''后面是数据库路径 自己修改,看上去是07版本的,如果是03版本的将前面的字符串换成 "provider=Microsoft.jet.OLEDB.4.0;data source="
WITH Rst
.Open "select * from 基站信息 where 地点='" & [b3] & "'", conn, adOpenKeyset, adLockOptimistic
If .RecordCount >0 Then
[B4]=.FIELDS("经度")
[B5]=.FIELDS("纬度")
[B6]=.FIELDS("PROVINCE")
ELSE: MsgBox "找不到该名称"
End If
end with
conn.Close
Set conn = Nothing
End Sub