Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2005
    Posts
    333

    Unanswered: Office 2007: Update Query

    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?

    Code:
    Private Sub btnUpdateSU_Click()
    On Error GoTo Err_btnUpdateSU_Click
        Dim stDocName As String
        stDocName = "updateSU"
        DoCmd.OpenQuery stDocName, acNormal, acEdit
        DoCmd.Requery
    Exit_btnUpdateSU_Click:
        Exit Sub
    Err_btnUpdateSU_Click:
        MsgBox Err.Description
        Resume Exit_btnUpdateSU_Click
        
    End Sub

  2. #2
    Join Date
    Feb 2005
    Posts
    333
    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.

    Code:
        Dim strSql As String
     
        strSql = "UPDATE IOModState INNER JOIN ActDetail ON IOModState.f_Tag = ActDetail.f_Tag " & _
                 "SET ActDetail.f_SU = [IOModState]![IOSU]"
        DoCmd****nSQL strSql
    The **** should be Run . I guess that the editor willn ot allow me to paste this code directly.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •