update query updates first record in a table

dylan_dog

Registered User.
Local time
Today, 09:58
Joined
Jan 2, 2012
Messages
40
Hi,

I have a problem with an update query. I have a table with a list of errors tbl_Prijave, where a user enters what is wrong with a slot machine, one field (Popravljeno) is set to "false" to indicate that it isn't fixed yet. There is a form with a checkbox where a user indicates that that particular error is fixed. A button runs an update query which should update fields in a table for that record and turn that field to "true". My problem is, that when I run the query from a form it doesn't update the record I want, but always the first record with "false" in the table. Field broj_prijave is what relates all the tables and when I manually run the query it asks me for "broj_prijave" and updates the correct record. This is the SQL for my query:

UPDATE tbl_Prijave SET tbl_Prijave.popravljeno = True, tbl_Prijave.datum_popravka = Now(), tbl_Prijave.popravio = [forms]![frm_Vpis_Novega_Popravila]![cmb_Popravljao]
WHERE (((tbl_Prijave.popravljeno)=False) AND ((tbl_Prijave.broj_prijave)=[forms]![frm_Vpis_Novega_Popravila]![txt_Broj_Prijave]))
WITH OWNERACCESS OPTION;

I just hope somebody understands what I wrote :-).

Regards, Samo
 
One thing in certain. Access queries are never unpredictable. They do exactly what you specify. I suspect that your criteria is incorrect.

As a practical mater, never test a boolean (yes/no) field as false. A boolean field can have values Null, False, or True. Null is not No. Always use "<> True" to test for false.
 
Always use "<> True" to test for false.
thumbsup.png
 
llkhoutx,

thanks for the tip about testing. Anyhow, I found out what I did wrong and it wasn't a query at all. In VBA that services the click event I had the part that writes some values to one table (vhat a user did to service the machine), then this:

Forms!frm_Prikazi_Prijavljene_IA.Requery

and only then this:

DoCmd.SetWarnings False

If CheckBoxName.Value = True Then
DoCmd.OpenQuery "qry_Popravljeno2"
End If

DoCmd.SetWarnings True

I moved the part that checks the CheckBoxName before the requery part and it works as intended :-).

Another question: when I try
to debug something: how can I see what gets passed to a query?

Thanks, Samo
 

Users who are viewing this thread

Back
Top Bottom