very basic code... need help

yepwingtim

Registered User.
Local time
Yesterday, 20:28
Joined
Jun 6, 2008
Messages
126
Private Sub Adequate_lining_Click()
CurrentDb.Execute "UPDATE History SET Adequate lining = 0",
dbFailOnError
End Sub

I have a table named "History" and a Yes/no checkbox named "Adequate lining".

I just added Adequate lining I want that checkbox to be true from the past entries i made....

Can someone explain to me why my code is wrong
________
Iolite Review
 
Last edited:
First of all, if you field has spaces you need to enclose it within square brackets []

Second, if you want to set the values to true then you can't set them to false (0). Use TRUE or -1.
 
hi bob thanks for the fast reply

Private Sub Adequate_lining_Click()
CurrentDb.Execute "UPDATE History SET [Adequate lining] = -1",
dbFailOnError
End Sub

here what i have now what i still have an expression error
________
Buy Vaporizers
 
Last edited:
So, what happens when you type that exact SQL into a query window and execute it? If it doesn't work there, you're not ready to put it into VB code.
 
it works now with sql
the thing is its not automatic
I have to double click on update query everytime

UPDATE Table3 SET Table3.[Take Test] = 1
WHERE (((Table3.[First Name])="X")) OR (((Table3.[Last Name Spouse])="X")) OR (((Table3.[Last Name])="X"));

is it possible while updating in a First Name which equals to X in a table to automatically set "Take Test" as True?
________
VAPORIZER WHOLESALE
 
Last edited:
I'm so confused, I thought you were having problems with the first update statement. What does the second one working in SQL have to do with it?

My question was:
what happens when you type that exact SQL into a query window and execute it?

regarding:
Code:
UPDATE History SET [Adequate lining] = -1

Did you answer that?

Is the other issue related? What does "automatically" mean?

Any reason you want to use DAO to do this? How 'bout:
Code:
Docmd.RunSQL "UPDATE History SET [Adequate lining] = True;"
 

Users who are viewing this thread

Back
Top Bottom