下拉菜单连接access数据库出现问题,求好心人来帮我看看
我想是下拉菜单显示access数据库的某张表的一个字段内容,就按照参考书写了一下一段代码,结果出现在“对应所需项目或序数的集合中未找到项目”这种错误,这该怎么解决,麻烦各位了。
Private Sub form_load()
bAdd = False
Dim strsql2 As String
Dim rs As New ADODB.Recordset
strsql2 = "select * from [船舶表] order by id"
Set rs = queryext(strsql2)
i = 0
With Combo1
Do While Not rs.EOF
.AddItem rs("船名") 在船舶表中第二个字段就是船名,第一个字段为id
.ItemData(i) = rs("id")
rs.MoveNext
i = i + 1
Loop
End With
strsql2 = "select * from [货物表] order by id"
Set rs = queryext(strsql2)
i = 0
With Combo2
Do While Not rs.EOF
.AddItem rs("货物名称")
.ItemData(i) = rs("id")
rs.MoveNext
i = i + 1
Loop
End With
strsql2 = "select * from [航线表] order by id"
Set rs = queryext(strsql2)
i = 0
With Combo3
Do While Not rs.EOF
.AddItem rs("航线名称")
.ItemData(i) = rs("id")
rs.MoveNext
i = i + 1
Loop
End With
strsql2 = "select a.id,日期,b.船名,b.船舶类型,b.总吨位,b.国籍,c.货物名称,货物数量,货物数量,d.航线名称"
strsql2 = strsql2 & "from 船舶申请表 a,船舶表 b,货物表 c,航线表 d"
strsqlw = strsql2 & "where a.船名=b.船名 and a.船舶类型=b.船舶类型 and a.总吨位=b.总吨位 and a.国籍=b.国籍 and a.货物名称=c.货物名称"
Adodc1.ConnectionString = conn
Adodc1.RecordSource = strsql2
Adodc1.Refresh
Set DataGrid1.DataSource = Adodc1
DataGrid1.Columns(0).Visible = False
End Sub
麻烦各位了。
[解决办法]
基础太差,先看看函数的定义与用法之类的吧。。。
queryext("select * from [用户登录]")