Loop not working

yepwingtim

Registered User.
Local time
Today, 09:12
Joined
Jun 6, 2008
Messages
126
Private Sub Text8_AfterUpdate()
Dim rst As DAO.Recordset
Set rst = Me.RecordsetClone
rst.MoveFirst
Do While Not (rst.BOF Or rst.EOF)
rst.Edit
rst![Run] = IIf(Me.checkbox = True, "1", "2")
rst.Update
rst.MoveNext
Loop
Me.Requery
Set rst = Nothing
End Sub

It reads the selected checkbox and gives all the record values as 1 if TRUE - vice-versa

I want it to be displayed according the checkbox
(checked means 1, unchecked means 2)
but it is just giving me a number that is either all 1's or all 2's in all the records

am i doing this loop wrong?

thanks
________
Hero honda hunk specifications
 
Last edited:
Me.checkbox is never going to change there. It is the value of the record you are on. So if it is true it will be true for all records if it is false it will be false for all records.

So, what is it you are really trying to accomplish here?
 
Hi,

I'm not realy into updating with a recordst, I would use a simple SQL statment:
Code:
CurrentDB.Execute "UPDATE tablName SET RUN = IIF(...,'1','2')"
 

Attachments

  • update.JPG
    update.JPG
    49.4 KB · Views: 111
Last edited:
If you can see from the picture,
even when the checkbox is checked. Run value would still be 2. Not 1.

perhaps im using a wrong loop?

As I said before -
boblarson said:
Me.checkbox is never going to change there. It is the value of the record you are on.

Emphasis should be on "It is the value of the record you are on."

So the focus never changes on any of the records the checkbox reference will ALWAYS be to the currently selected record. So, is this an UNBOUND checkbox? If so, you should just add the yes/no field to the table and then you can select it and you wouldn't need to even run an update query or recordset because it would already have the correct value.
 
Continuous forms do not play nicely with unbound controls because in reality there is only ONE control there but it is DISPLAYED for each record.
 
Thanks for the input Bob~

The checkbox is a field
is there a way to get around this?

Thanks~
________
R25
 
Last edited:
Thanks for the input Bob~

The checkbox is a field
is there a way to get around this?

Thanks~

The checkbox is a field in a table and is on the form? Then what are you trying to update with the code? I don't get it then.
 
the checkbox field is a field from Table1

This isn't the actual table or form. But answering the question helps me use it on the actual table and form.

Thanks
________
Launch box
 

Attachments

  • war.JPG
    war.JPG
    67.3 KB · Views: 105
Last edited:
the checkbox field is a field from Table1

This isn't the actual table or form.
Well, I hate to say it but not providing the real information makes it extremely difficult to answer your question intelligently. I fear that you are trying to do something which you don't need to do because it can be done another, more efficient, way.
But answering the question helps me use it on the actual table and form.
Again, can't answer a question that doesn't exist. Please provide the REAL reason why you are trying to do this and we might make some progress.
 
Table 1 is actually a calculator I made.
Our CSR receives the call and service quotes are made on the fly

Let's say client wants the (2 records)

living room - walls painted, floors cleaned
kitchen - cabinet painted, floors waxed

Checks are made to walls painted, floors cleaned
Checks are made to cabinet painted, floors waxed

The AfterUpdate field is actually an "fixed price" where we can lower the price or even up it during the phone which changes the total price (Run Field) on the fly

I will show a picture when I have a chance. i guess using docmd.runsql is fine for now

Thanks again~
________
HONDA CHF50
 
Last edited:

Users who are viewing this thread

Back
Top Bottom