Private Sub 科目编码_BeforeUpdate(Cancel As Integer)
Dim cnnmx As ADODB.Connection
Dim rsmx As ADODB.Recordset
Dim mysql As String
tyu = 科目编码.Value
Set rsmx = New ADODB.Recordset
mysql = "select 科目名称 AS RRR from 总账科目表 where 科目编码 = tyu "
rsmx.Open mysql, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
总账科目.Value = RRR
错误不只一个:
一、
tyu = 科目编码.Value '变量tyu未声明
二、
mysql = "select 科目名称 AS RRR from 总账科目表 where 科目编码 = tyu "
科目编码字段如是字符型时应为
mysql = "select 科目名称 AS RRR from 总账科目表 where 科目编码 = '" & tyu & "'"
科目编码字段如是数字型时应为
mysql = "select 科目名称 AS RRR from 总账科目表 where 科目编码 = " & tyu