I have this stored procedure that I run in Access.
Private Sub ReviewTrns_Click()
Dim cdb As DAO.Database, qdf As DAO.QueryDef
Set cdb = CurrentDb
Set qdf = cdb.CreateQueryDef("")
qdf.Connect = cdb.TableDefs("dbo_FreeShipping").Connect
qdf.SQL = "EXEC dbo.UpdateTrns"
qdf.ReturnsRecords = False
qdf.Execute dbFailOnError
Set qdf = Nothing
Set cdb = Nothing
MsgBox "Records Updated!"
End Sub
It works perfectly. dbo_FreeShipping
is a linked table, dbo.UpdateTrns
is a stored procedure. I also want to add input value for parameter @variable1
Could it be done with message box input?
答案 0 :(得分:0)
只需将用户输入的结果连接到sql调用即可。尝试类似:
Private Sub ReviewTrns_Click()
Dim input As String
input = InputBox("Enter variable1") //get the user input
Dim cdb As DAO.Database, qdf As DAO.QueryDef
Set cdb = CurrentDb
Set qdf = cdb.CreateQueryDef("")
qdf.Connect = cdb.TableDefs("dbo_FreeShipping").Connect
qdf.SQL = "EXEC dbo.UpdateTrns @variable1='" & input & "'" // concatenate parameter
qdf.ReturnsRecords = False
qdf.Execute dbFailOnError
Set qdf = Nothing
Set cdb = Nothing
MsgBox "Records Updated!"
End Sub
答案 1 :(得分:0)
我从gba中的警告框获取输入变量的goto方法是InputBox()
。例如:
Public myStr as String
public sub GetInputStr()
myStr = InputBox("Enter your variable here")
end sub
然后您应该能够在模块中的其他子设备中使用myStr。希望这有帮助!