Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

If a field equals a certain value then fill in other field with value

Status
Not open for further replies.

EvilTwinOfAtrus

Technical User
Dec 30, 2002
56
GB
Hi,

Sorry for the rubbish title I gave you, hopefully I can explain better here. I have a table called 'tblBalloon'. This table contains a true/false field for 3 colours. The field names are 'Red', 'Yellow' and 'Blue' respectively. in each field, -1 stands for True and 0 stands for False (this is because I made the table using an amend query). What I want to do, when i click a button on a form (which does not really need to be named), is to filled in the 'Colour' field in 'tblBalloon' with the appropriate colour word.

This is the code that I have at the moment:

If tblBalloon.Red = -1 Then
tblBalloon.Colour = "Red"
End If

However, when I run the code it gives a 'Variable Not Defined' error and highlights the first 'tblBalloon' instance. Can anyone help me?

Many Thanks,
Karl
 
Karl,

You need to refer to the Form object and not the table.

Try this for the code of the click option on your button -

If Me.Red=-1 Then
Me.Colour.Value="Red"
End If

As long as the form has the control source for your fields bound to the table you desire you should be all set.
 
Aaaah, sorry. I completely forgot to mention that my code is 'Call'ed upon by the button because it is a module.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top