我创建了一个dlookup来搜索我刚从组合框中添加的表([copy of tbltypeofasset])记录来查找id。我想从这里将这个值插入到另一个表中,只是为了测试它是否工作。下面是我试图使用的代码。
Private Sub Button_Click()
CurrentDb.Execute "INSERT INTO [Copy Of tblTypeOfAsset](Manufacturer, Model, Version, CalInterval) Values ('" & Me.CBOFirm & "','" & Me.CBOComms & "' , '" & Me.CBOSpSettings & "','" & Me.CBOConfigP & "');"
Dim varx As Variant
varx = DLookup("TypeID", "[Copy Of tblTypeOfAsset]", "[Manufacturer] = Forms![JA_Data_Input_Info]!CBOFirm And [Model] = Forms![JA_Data_Input_Info]!CBOComms And [Version] = Forms![JA_Data_Input_Info]!CBOSpSettings")
CurrentDb.Execute "INSERT INTO 1test (test) VALUES ('varx')"
End Sub
这段代码插入一个sting'varx',而不是id值,如果没有逗号,我会得到一个“runtime error:'3061”:参数太少。应为1。“
1条答案
按热度按时间kq0g1dla1#
连接值和sql: