Office中国论坛/Access中国论坛
标题:
[求教]为什么总是变数字?正确的代码该怎样写?
[打印本页]
作者:
syan23
时间:
2005-3-23 22:22
标题:
[求教]为什么总是变数字?正确的代码该怎样写?
请教:
用ADO将表 "代码" 里的代码字段数据追加到 表 "代码2"里面,为什么追加过去总是变成数字?正确的代码该怎样写?
Private Sub Command0_Click()
Dim conn As New ADODB.Connection
Set conn = CurrentProject.Connection
Dim rst As New ADODB.Recordset
Dim i As Integer
rst.Open "代码", conn, adOpenKeyset, adLockOptimistic
rst.MoveFirst
For i = 1 To rst.RecordCount
DoCmd.RunSQL "INSERT INTO 代码2 ( 代码) SELECT " & rst("代码")
rst.MoveNext
Next i
End Sub
详见附件!
[attach]9554[/attach]
[此贴子已经被作者于2005-3-23 14:24:50编辑过]
作者:
Trynew
时间:
2005-3-23 23:21
DoCmd.RunSQL "INSERT INTO 代码2 ( 代码) SELECT " & rst("代码")
改为加单引号:DoCmd.RunSQL "INSERT INTO 代码2 ( 代码) SELECT '" & rst("代码") & "'"
作者:
syan23
时间:
2005-3-24 06:42
Thank you very much!
Studying......
欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/)
Powered by Discuz! X3.3