Excuting SQL select statement in VBA

  • Hi all, I have an SQL select statment that I want to run when a button is clicked:

    SELECT ROOM.ROOM_ID FROM ROOM WHERE (((ROOM.FACILITIES)Like'" & Combo22.Column(0) & "'))"

    the statement takes values from a combo box as a constraint.

    How can I do that in VBA Access?

  • Re: Excuting SQL select statement in VBA

    or DoCmd.RunSQL

    If you want to run an action query then you will probably want to turn the warnings off, I use the following two procedures to do this:

    Public Sub mp_ConfirmOff()
        Application.SetOption "Confirm Action Queries", False
        DoCmd.SetWarnings False
    End Sub
    Public Sub mp_ConfirmOn()
        Application.SetOption "Confirm Action Queries", True
        DoCmd.SetWarnings True
    End Sub


Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!