Ms access 在用户窗体内调用值';s使用变量进行控制
我试图从表单中调用一个值,将其放到SQL中。但它不起作用Ms access 在用户窗体内调用值';s使用变量进行控制,ms-access,vba,Ms Access,Vba,我试图从表单中调用一个值,将其放到SQL中。但它不起作用 Dim n As integer Dim StrSQL As String Dim mymain As Variant Dim inputform as string mymain = Array("well_name", "well_alias", "well_short") n=0 --try to loop inputform="form_inputwell"+mymain(n) StrSQL = "INSERT INTO dat
Dim n As integer
Dim StrSQL As String
Dim mymain As Variant
Dim inputform as string
mymain = Array("well_name", "well_alias", "well_short")
n=0
--try to loop
inputform="form_inputwell"+mymain(n)
StrSQL = "INSERT INTO databasewell (bh_name) VALUES ('" & inputform & "');"
DoCmd.RunSQL StrSQL
n=n+1
--loop end
有没有办法调用数组中哪个字段的值?
例如:
form_inputwell.well_name called by declaring "form_inputwell"+mymain(1)
我想这就是你想要做的:
Dim n As Integer
Dim StrSQL As String
Dim mymain As Variant
Dim inputform As String
mymain = Array("well_name", "well_alias", "well_short")
For n = LBound(mymain) To UBound(mymain)
inputform = form_inputwell.Controls(mymain(n)).Value
StrSQL = "INSERT INTO databasewell (bh_name) VALUES ('" & inputform & "');"
DoCmd.RunSQL StrSQL
Next n
我想这就是你想要做的:
Dim n As Integer
Dim StrSQL As String
Dim mymain As Variant
Dim inputform As String
mymain = Array("well_name", "well_alias", "well_short")
For n = LBound(mymain) To UBound(mymain)
inputform = form_inputwell.Controls(mymain(n)).Value
StrSQL = "INSERT INTO databasewell (bh_name) VALUES ('" & inputform & "');"
DoCmd.RunSQL StrSQL
Next n
我找到了我的解决办法,不过还是要谢谢你的帮助
paramtemp = Forms("form name").Controls(field in form).Value
我找到了我的解决办法,不过还是要谢谢你的帮助
paramtemp = Forms("form name").Controls(field in form).Value
根据你的代码,输入表单仍然是“form\u inputwell.well\u name”,我想。我想要的是form\u inputwell.well\u name.Ok的值!因此,实际上,您需要名为
well\u name
的控件中的值?尝试一下编辑!;)根据你的代码,输入表单仍然是“form\u inputwell.well\u name”,我想。我想要的是form\u inputwell.well\u name.Ok的值!因此,实际上,您需要名为well\u name
的控件中的值?尝试一下编辑!;)