You'd be far better off using the original code I gave, where you build the
SQL in code and execute that string, rather than using a stored query.
Depending on what the data type of your fields are, it would be something
like:
strSQL = "UPDATE Esercizi_pubblici " & _
"SET Esercizi_pubblici.Attività = " & _
[Forms]![Esercizi_pubblici_Update]![CboAttività] & _
", Esercizi_pubblici.Tipologia_Esercizio = " & _
[Forms]![Esercizi_pubblici_Update]![CboEsercizio] & _
"WHERE Esercizi_pubblici.Attività = " & _
[Forms]![Esercizi_pubblici_Update]![Attivita] & _
" AND " & _
"Esercizi_pubblici.Tipologia_Esercizio) = " & _
[Forms]![Esercizi_pubblici_Update]![Esercizio]
That assumes that all of the fields are numeric. For text fields, you need
to ensure that there are quotes around the values that are bing passed. For
instance, if Attività is a text field, you'd use
strSQL = "UPDATE Esercizi_pubblici " & _
"SET Esercizi_pubblici.Attività = " & _
Chr$(34) & _
[Forms]![Esercizi_pubblici_Update]![CboAttività] & _
Chr$(34) & _
", Esercizi_pubblici.Tipologia_Esercizio = " & _
[Forms]![Esercizi_pubblici_Update]![CboEsercizio] & _
"WHERE Esercizi_pubblici.Attività = " & _
[Forms]![Esercizi_pubblici_Update]![Attivita] & _
" AND " & _
"Esercizi_pubblici.Tipologia_Esercizio) = " & _
[Forms]![Esercizi_pubblici_Update]![Esercizio]
--
Doug Steele, Microsoft Access MVP
(no e-mails, please!)
John said:
Unfortunatly I am still experienced difficulties.
The message error is "to few parameters, expected 4".
I think because the update query is parameterized query and I should pass
the parameter in the code.
The SQL view is
UPDATE Esercizi_pubblici SET Esercizi_pubblici.Attività =
[Forms]![Esercizi_pubblici_Update]![CboAttività],
Esercizi_pubblici.Tipologia_Esercizio =
[Forms]![Esercizi_pubblici_Update]![CboEsercizio]
WHERE
(((Esercizi_pubblici.Attività)=[Forms]![Esercizi_pubblici_Update]![Attivita]
)
((Esercizi_pubblici.Tipologia_Esercizio)=[Forms]![Esercizi_pubblici_Update]!
[Esercizio]));
How may I integrated this in the code?
Thanks again for your help and time.
John