• June 13, 2021

PHSARIT

Bring Technology Ideas with you

 Using Textbox in MS Access to run SQL Command

Have you ever try to run SQL Statement in Microsoft Access Form? It is a very powerful tool for beginner to start learning SQL programming language. By opening Microsoft Access then go to Create, by creating a new form—> I prefer choosing Modal dialogue form

    Then go to Design Tab and choose Textbox, Command Button, Label to design the form

    Image may contain: text

      After please name those tools as you wish but make sure that you have correct from our code to yours. You can copy as below:

      Private Sub bntRun_Click()
      Form_Form2.txtstring.SetFocus
      If Me.txtstring.Text = “” Then
      MsgBox “Please enter sql command”
      Exit Sub
      Else
      Dim query As String

      Form_Form2.txtstring.SetFocus
      query = Me.txtstring.Text
      DoCmd.RunSQL (query)
      End If

      Related post