Update SQL

radek225

Registered User.
Local time
Today, 14:04
Joined
Apr 4, 2013
Messages
307
I would like to paste value from tblZlecenia.nowe_id to tblDocelowa.nowe_id (number fields) in every record where tblZlecenia.id_zlecenia = tblDocelowa.id_zlecenia (text fields). I found some code and remodeled it, so now my code look like this:

Code:
Private Sub Polecenie0_Click()
Dim strSQL As String
Dim recIn As Recordset
strSQL = "SELECT * FROM tblZlecenia"
  Set recIn = CurrentDb.OpenRecordset(strSQL)
  While Not recIn.EOF
    strSQL = _
        "UPDATE tblDocelowa " & _
        "SET nowe_id = recIn!nowe_id " & _
        "WHERE ID_Zlecenia ='" & recIn!id_zlecenia & "'"
    CurrentDb.Execute strSQL, dbFailOnError
     recIn.MoveNext
    
  Wend
  recIn.Close
End Sub

It doesn't works :/ Please guys, help me!
 
Why have you not concatenated the value?
Code:
"SET nowe_id = [COLOR=Red][B]" &[/B][/COLOR] recIn!nowe_id [COLOR=Red][B]& _[/B][/COLOR]
 
Now MS Access has problem with operator in this line
Code:
Private Sub Polecenie0_Click()
Dim strSQL As String
Dim recIn As Recordset
strSQL = "SELECT * FROM Zlecenia"
  Set recIn = CurrentDb.OpenRecordset(strSQL)
  While Not recIn.EOF
    strSQL = _
        "UPDATE tblDocelowa " & _
        "SET nowe_id = " & recIn!nowe_id & _
 [COLOR="Red"]       "WHERE ID_Zlecenia ='" & recIn!id_zlecenia & "'"[/COLOR]
    CurrentDb.Execute strSQL, dbFailOnError
     recIn.MoveNext
    
  Wend
  recIn.Close
End Sub
Because I think I don't know all of the rules...
 
It works! THX!!!! Do you have some link where could I find rules of the notation? I was looking for sometime, but I have not found (only short description)
 
Here is a post, where I gave explanation for a few months back to another user ! Hope this helps.
 

Users who are viewing this thread

Back
Top Bottom