none
Correction needed RRS feed

  • Question

  • Could you tell me if this is correct?

        

    Private Function UpdateHours()

    If Not IsNull(Me.reasonofmissing) Then

        Dim strSQLmissing As String
        strSQLmissing = "UPDATE Days2012 SET '[" & Me.ID & "]' = '[" & Me.reasonofmissing & "]' Where 'IDdays' = '[" & Me.ID & "]';"
        CurrentDb.Execute strSQLmissing, dbFailOnError

    End If

    End Function

    thanks in advance

    Monday, February 13, 2012 3:38 PM

Answers

  • Hi hefterbrumi,

    What field in table Days2012 are you trying to update?

    In your SQL you set Me.ID to Me.reasonofmissing, which both are Form fields. Please explain?

    If field Me.reasonofmissing and Me.ID are both Text fields, and you want to update this in table Days2012, the SQL syntax would be something like this:

    Public Function UpdateHours()
    
    If Not IsNull(Me.reasonofmissing) Then
    
        Dim strSQLmissing As String
        strSQLmissing = "UPDATE Days2012 SET [txtYourFieldReasonOfMissing] ='" & Me.reasonofmissing & "'" & _
        " Where [IDdays] ='" & Me.ID & "'" & ";"
        CurrentDb.Execute strSQLmissing, dbFailOnError
    
    End If
    
    End Function

    Hope this helps,


    Daniel van den Berg | Washington, USA | "Anticipate the difficult by managing the easy"

    • Marked as answer by hefterbrumi Thursday, February 16, 2012 11:25 AM
    Monday, February 13, 2012 4:18 PM
    Moderator

All replies

  • Hi hefterbrumi,

    What field in table Days2012 are you trying to update?

    In your SQL you set Me.ID to Me.reasonofmissing, which both are Form fields. Please explain?

    If field Me.reasonofmissing and Me.ID are both Text fields, and you want to update this in table Days2012, the SQL syntax would be something like this:

    Public Function UpdateHours()
    
    If Not IsNull(Me.reasonofmissing) Then
    
        Dim strSQLmissing As String
        strSQLmissing = "UPDATE Days2012 SET [txtYourFieldReasonOfMissing] ='" & Me.reasonofmissing & "'" & _
        " Where [IDdays] ='" & Me.ID & "'" & ";"
        CurrentDb.Execute strSQLmissing, dbFailOnError
    
    End If
    
    End Function

    Hope this helps,


    Daniel van den Berg | Washington, USA | "Anticipate the difficult by managing the easy"

    • Marked as answer by hefterbrumi Thursday, February 16, 2012 11:25 AM
    Monday, February 13, 2012 4:18 PM
    Moderator
  • Thx I give it a try

    The problem is, that i'd like to edit record in a column that is picked by the user. So I dont know wich column will be chosen. It depends on a text field that changes (ID)

    • Edited by hefterbrumi Monday, February 13, 2012 6:27 PM
    Monday, February 13, 2012 6:18 PM