|
我的例子是:
比如在一个Form: Main 里选择
Main里3个下拉菜单 Brand (BrandSel) Chip (ChipSel) productmanager(ProdmanHW) 下拉菜单里可选择以下3个Table中得值 点击Button:Show 实现对总表中数据得查询(因为以上三个表全部关系连接到一个数据库(一个总表HW)HW:Brand,chip,manager,.......
结果显示在另一个Form:Hardware 里.显示为Brand chip manager...
control source分别为Brand_name,Chip_name,Product_manager.....
code红字那段不懂为什么,谁能在这个例子下给我解释一下啊,那段Code是用什么意思实现数据查询得.万分感谢
show_click
private Sub show_Click()
On Error GoTo Err_show_Click
Dim stDocName As String
Dim stLinkCriteria As String
Dim BrandKrit As String
Dim ChipKrit As String
Dim StatKrit As String
Dim ProdKrit As String
......
BrandKrit = "[Brand_name]=" & "'" & Me![BrandSel] & "'"
ChipKrit = "[Chip_name]=" & "'" & Me![ChipSel] & "'"
ProdKrit = "[Product_manager]=" & "'" & Me![ProdManHW] & "'"
If Len(BrandKrit) > 15 Then
stLinkCriteria = BrandKrit
End If
If Len(ChipKrit) > 14 Then
If stLinkCriteria = "" Then
stLinkCriteria = ChipKrit
Else
stLinkCriteria = stLinkCriteria & " AND " & ChipKrit
End If
End If
If Len(ProdKrit) > 20 Then
If stLinkCriteria = "" Then
stLinkCriteria = ProdKrit
Else
stLinkCriteria = stLinkCriteria & " AND " & ProdKrit
End If
End If
If forms_show Then
DoCmd.OpenForm stDocName, , , stLinkCriteria
If Len(ProdKrit) > 20 Then
Forms![Hardware]![OKButton].Visible = True
Else
Forms![Hardware]![OKButton].Visible = False
End If
Else
DoCmd.OpenForm stDocName, , , stLinkCriteria, , acHidden
End If
Exit_show_Click:
Exit Sub
...
3个table :
Brand
Brand_name
空白数值
Siemens
Brand B
A&M
Electone
AH
NHS
Hansaton
Miracle Ear
Lavis
Kind
Amplivox
Siemens phase out
Sountex
<TD borderCo |
|