I have an update query that works fine if I run it directly from Access. I'm trying to run this query from a form using the click event of a command button but the query does not seems to run. The code is shown below. Is there any reason that this code would not work for an Update query?
Private Sub btnUpdateSU_Click()
On Error GoTo Err_btnUpdateSU_Click
Dim stDocName As String
stDocName = "updateSU"
DoCmd.OpenQuery stDocName, acNormal, acEdit
If I put the SQL directly into the VBA the query runs as well. This may be the way to go but I wanted to make it easier for the user to update the query. Not always a good thing to have them modify code to change a query.
Dim strSql As String
strSql = "UPDATE IOModState INNER JOIN ActDetail ON IOModState.f_Tag = ActDetail.f_Tag " & _
"SET ActDetail.f_SU = [IOModState]![IOSU]"
The **** should be Run . I guess that the editor willn ot allow me to paste this code directly.