Can someone tell me how I can assign a SQL command to a button on a form? I know how to assign a VBA command to a button, but not SQL command to a button. Can someone please orient me.
ToeShot: DoCmd.RunSQL will generate error number 2342 for Select statements. You can use it only for action queries...
Dalex17's post is a little ambiguous...What exactly is needed?
As a general example:
Sub CommandCutton_Click()
Dim strSQL$
Dim rst As DAO.Recordset
strSQL = "Select * From TableName;"
'now you do whatever you want with the SQL:
RecordSource = strSQL
CurrentDb.QueryDefs("AnyQueryName".SQL = strSQL
Set rst = CurrentDb.OpenRecordset(strSQL)
End Sub
Regards,
Daniel Vlas
Systems Consultant
danvlas@yahoo.com
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.