|
大家好
现在我有个窗体,窗体上有高度和宽度两个输入框 想从 “最适型材查询”这个查询里面筛选出记录,条件是:
1:筛选出的查询表里的宽度字段和高度字段的值分别大于等于窗体上输入的宽度和高度的值
2:查询表里的高度字段的值减去输入高度的值,差值为A,
查询表里的宽度字段的值减去输入宽度的值,差值为B,
C=A+B
查询出的列,按照C值由小到大排列,只显示10列即可。
意思就是是查找出最和输入的长宽值最接近的列,我写了一些,写不下去了,麻烦帮忙补充一下,谢谢
Dim rs As New ADODB.Recordset
Dim ssql As String
Dim i As Long, A As Long, B As Long, C As Long
ssql = "select * from 最适型材查询 where [高度] >= & Me.高度 and & [宽度] >= & Me.宽度 "
rs.Open ssql, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
For i = 1 To rs.RecordCount
A = [宽度].Value - Me.宽度.Value
B = [高度].Value - Me.高度.Value
C = A + B
Next i
'让子窗体应用窗体查询
Me.最适型材查询子窗体.Form.Filter = ssql
Me.最适型材查询子窗体.Form.FilterOn = True
|
|