|
- Option Compare Database
- Option Explicit
- Private Sub 货品编码_AfterUpdate()
- Dim v As String
- If Not IsNull(货品编码.Value) Then
- v = Join(货品编码.Value, ",")
- End If
- Me.货品名称 = lookValue(v)
- End Sub
- Private Function lookValue(c As String) As String
- Dim sql As String
- If c <> "" Then
- sql = "SELECT 货品名称 FROM 货品表 WHERE 货品编码 IN(" & c & ")"
- Dim rs As ADODB.Recordset
- Set rs = CurrentProject.Connection.Execute(sql)
- lookValue = rs.GetString(, , ",", ",")
- rs.Close
- Set rs = Nothing
- If Len(lookValue) > 0 Then
- lookValue = Left(lookValue, Len(lookValue) - 1)
- End If
- Debug.Print lookValue
- End If
- End Function
复制代码 技术要点:
1、Join(货品编码.Value, ",") 这时的 Value 是一个数组
2、rs.GetString(, , ",", ",") 将记录集转换为字符串 |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|