问题描述
好的我有两个列表框,这些列表框由来自Access Db的数据填充,它由if语句填充,如果数据与今天的日期相同,则将其放入列表框1中,如果它的明天日期,但它在列表框2中。
Private Sub orderstatus()
''-------
imputdate = Text30.Text
customDate = DateValue(imputdate)
''--------
Dim sql As String
sql ="从订单中选择*
使用Data1
.RecordSource = sql
.Refresh
.Recordset.MoveFirst
Do Until .Recordset.EOF
On Error Resume Next
If .Recordset.Fields( 7)= customDate然后
List4(1).AddItem .Recordset(" Order_ID")
ElseIf .Recordset.Fields(7)= customDate + 1然后
List4(0).AddItem .Recordset(" Order_ID")
结束如果
。 Recordset.MoveNext
循环
结束
结束子
列表框显示order_ID
工作正常,我遇到的问题是我想点击任一列表框中的order_Id和该订单ID的数据来填充一组文本框,
这是我迄今为止所得到的
Private Sub Command25_Click()
rs.MoveFirst
直到rs.EOF
如果rs.Fields(1)= List4(1)。然后
Text29.Text = rs.Fields(0)
Text1.Text = rs.Fields(1)
Text2 .Text = rs.Fields(2)
Text3.Text = rs.Fields(3)
Text4.Text = rs.Fields(4)
Text5.Text = rs.Fields(5)
Text6.Text = rs.Fields(6)
Text7.Text = rs.Fields(9)
其他:rs.MoveNext
结束如果
循环
我确定之后应该有什么东西list4(1)。但我一直在寻找网络,我无法找到任何东西:((
我希望这样做:D $ / b
我希望你能帮忙!
非常感谢
Stu
Ps即时通讯使用Vb6
OK i have two listboxes that are populated by data from a Access Db, its populated by a if statement sayin if the data is the same as todays date put it in list box1 and if its tomorrows date but it in listbox 2.
Private Sub orderstatus()
''-------
imputdate = Text30.Text
customDate = DateValue(imputdate)
''--------
Dim sql As String
sql = "Select * from Orders"
With Data1
.RecordSource = sql
.Refresh
.Recordset.MoveFirst
Do Until .Recordset.EOF
On Error Resume Next
If .Recordset.Fields(7) = customDate Then
List4(1).AddItem .Recordset("Order_ID")
ElseIf .Recordset.Fields(7) = customDate + 1 Then
List4(0).AddItem .Recordset("Order_ID")
End If
.Recordset.MoveNext
Loop
End With
End Sub
The listboxes display an order_ID
that works fine, the problem im having is that i want to click on a order_Id in either of the list boxes and the data for that order id to populate a numer of text boxes,
this is kinda what i got so far
Private Sub Command25_Click()
rs.MoveFirst
Do Until rs.EOF
If rs.Fields(1) = List4(1). Then
Text29.Text = rs.Fields(0)
Text1.Text = rs.Fields(1)
Text2.Text = rs.Fields(2)
Text3.Text = rs.Fields(3)
Text4.Text = rs.Fields(4)
Text5.Text = rs.Fields(5)
Text6.Text = rs.Fields(6)
Text7.Text = rs.Fields(9)
Else: rs.MoveNext
End If
Loop
Im sure there should be something after the list4(1). but ive been looking though the net and i cant find anything :((
I hope this make sence :D
and i hope you can help !
Thanks a lot
Stu
P.s im using Vb6
推荐答案
在操作:然后你必须使用控制数组。
In Op: then you have to use Control array.
这篇关于使用列表框中的选定值从Db获取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!