现有“表1”,表1有字段[配方],[备注]。
由表1生成数据表窗体[窗体1],小弟作代码如下:
Private Sub 备注_GOTFOCUS()
If Me.配方 = "AAA" Then
Me.备注 = 1
ElseIf Me.配方 = "BBB" Then
Me.备注 = 2
ElseIf Me.配方 = "CCC" Then
Me.备注 = 3
Else
Me.备注 = 4
End If
End Sub
用select case吧
Private Sub 配方_AfterUpdate()
Select Case Me.配方.Value
Case "AAA"
Me.备注 = 1
Case "BBB"
Me.备注 = 2
Case "CCC"
Me.备注 = 3
Case Else
Me.备注 = 4
End Select