访问 - 将输入框值保存到数据表(表)

时间:2015-05-20 08:04:28

标签: access-vba inputbox

我遇到了一个问题我已经尝试了一些我在互联网上找到的结果,但我似乎无法让它发挥作用。

'Pop-up for information where the pv is located and save it to the db
Private Sub Destroyed_pv_Click()
If Me.Destroyed_pv = vbTrue Then
    Dim Strg As String, hyperlink_pv_var$
    Strg = "Typ your location here..."
    Strg = InputBox("Fill in the location of the PV.", "PV Location", Strg)
    If Strg = "" Then
        hyperlink_pv_var$ = "You didn't fill in the box"
    Else
        hyperlink_pv_var$ = "Location of the PV is: " &vbNewLine & Strg
    End If
    MsgBox hyperlink_pv_var$
Else
End If
End Sub

我需要将hyperlink_pv_var $的结果放在我的数据表(表格)中 我试过这个

DoCmd.RunSQL "INSERT INTO Registratie formulier.PV_Location"_&"(PV_Location) VALUES "_&"(hyperlink_pv_var$);"

但这不起作用。我希望你们能帮我解决这个问题。

干杯, 帕特里克

1 个答案:

答案 0 :(得分:0)

尝试:

DoCmd.RunSQL "INSERT INTO [Registratie formulier].[PV_Location] " _
    & "(PV_Location) VALUES " _
    & "('" & hyperlink_pv_var$ & "');"

注意:

  1. 如果字段,表或数据库名称包含空格,请用[ ]
  2. 括起来
  3. 此代码假定hyperlink_pv_var$始终为字符串。
相关问题