|
5#
楼主 |
发表于 2013-3-21 22:29:39
|
只看该作者
刚刚通过Dlookup和If已经实现啦,作为新手忙的一身汗啊!
Private Sub 产品名称_AfterUpdate()
Dim StrTemp As String
Dim rs As New ADODB.Recordset
StrTemp = "Select * From 历史价格查询 Where 产品名称=" & "'" & Me.产品名称 & "' And 客户名称=" & "'" & Forms![主窗体]![客户名称] & "'"
rs.Open StrTemp, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
If rs.EOF = True Then
Me.单价 = DLookup("[价格1]", "[件价格]", "[产品名称]='" & [Forms]![主窗体]![子窗体]![产品名称] & "'")
Else
rs.MoveLast
If rs.EOF = False Then
Me.单价 = rs("单价")
End If
End If
End Sub
Private Sub 单位_AfterUpdate()
If 单位 <> "件" Then
Me.单价 = DLookup("[价格2]", "[包价格]", "[产品名称]='" & [Forms]![主窗体]![子窗体]![产品名称] & "'")
End If
End Sub
Private Sub 单位_BeforeUpdate(Cancel As Integer)
End Sub
|
|