473,495 Members | 1,967 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to reference a field in a specific table?

5 New Member
I have a combo box in a form and want the background color to change if the name is female. Below is my code but nothing changes.

I'm new at this and this is basic but I'm good at figuring things out if I'm put in the right direction, Please help.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Combo5_Change()
  2. If [bowlers]![m/f] = "female" Then
  3. [Combo5].BackColor = "65535"
  4. Else
  5. [Combo5].BackColor = "16777215"
  6. End If
  7.  
  8. End Sub
Feb 3 '11 #1
8 6105
mshmyob
904 Recognized Expert Contributor
Since the backcolor property is a long number you do not need to enclose the value in quotes.

cheers,
Feb 3 '11 #2
Jim Petrin
5 New Member
Now Microsoft access error says in can't find the field. Am I referencing the field properly? Or do I have to first activate the table?

Expand|Select|Wrap|Line Numbers
  1. Private Sub Combo5_Change()
  2. If [bowler]![gender] = "female" Then
  3. [Combo5].BackColor = 65535
  4. Else
  5. [Combo5].BackColor = 16777215
  6. End If
Feb 3 '11 #3
NeoPa
32,556 Recognized Expert Moderator MVP
Jim, What are you trying to check? The value of the ComboBox?

The event you should be using is the AfterUpdate event BTW.

Here's some example code that may be along the right lines, but you need to explain your situation better if you hope to get pertinent help :
Expand|Select|Wrap|Line Numbers
  1. Private Sub Combo5_AfterUpdate()
  2.     With Me.Combo5
  3.         .BackColor = IIf(.Value = "Female", 65535, 16777215)
  4.     End With
  5. End Sub
Feb 3 '11 #4
Jim Petrin
5 New Member
I tried your suggestion but that's not what I am trying to check. I'm trying to check the value of the field [Gender] which is located in the same table as the name in the combo box. The table name is [Bowlers].
Feb 3 '11 #5
NeoPa
32,556 Recognized Expert Moderator MVP
It wasn't a suggestion Jim. It was an illustration of concept. I also pointed out that more apposite help is unlikely without some more information coming from yourself.

While your latest post is some more information, it is little more than an indication of what cannot be relied upon. I now know it's not that particular control that you need to refer to, but you give no clue as to whether there is another control on the form that can be referenced, or alternatively, if a separate reference to a table is indeed required (which is unusual), how the specific record in that table could be identified.

The point I was making wasn't unimportant. I suggest you need to consider that before posting again. We're generally willing to help, but you need to put some effort in, even if it's only to explain your situation clearly enough so that we know what the question is.
Feb 3 '11 #6
mshmyob
904 Recognized Expert Contributor
Jim you are referencing the field in the table incorrectly.

The easiest way to reference the field is to have the table bound to the form and then place a text box control on the form that is bound to the gender field. As you move through the records in the table using the form the value in the text box control will update based on the value in the table records automatically. You can then check the status of the text box control on the form anytime you wish. If you do not want the text box control to be seen just set the visible property to false.

Does this make any sense to you?

cheers,
Feb 3 '11 #7
Jim Petrin
5 New Member
Thank you mshmyob. That is very helpful. As evident I'm not a developer and trying to make access work for a youth bowling tournament and make our life easier on the paperwork side. This will set me in the right direction.
Feb 3 '11 #8
mshmyob
904 Recognized Expert Contributor
Good luck. If you have any other questions we will be here to hopefully answer them to your satisfaction.

cheers,
Feb 3 '11 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

2
2614
by: Benny | last post by:
Dear All, Suppose in the program a record is added to a table whose primary key is a identity field. If I really want to get the lastest value for that field after the insertion, is it the best...
3
1904
by: Oren | last post by:
Hi, I have an Access application with linked tables via ODBC to MSSQL server 2000. Having a weird problem, probably something i've done while not being aware of (kinda newbie). the last 20...
2
1871
by: serge | last post by:
Can you create an UPDATE TRIGGER and use some type of code to figure out which SP just updated the current table? If not how can i achieve what i want? I tried to run SQL Profiler and i don't...
7
3223
by: Marco Simone | last post by:
Hi, What is your opinion about using Lookup field in table. I would like to use lookup field in table 1, so that I can choose data in combo box from table 2. Is this good design of database? ...
1
1435
by: deko | last post by:
If I allow users to create a QueryDef by entering an sql statement in a text box, can I restrict that query to a specific table? Is there some way to throw an error based on what table a query...
2
7455
by: UJ | last post by:
I'm getting a dataset back from a web service and I want to verify that the table I want exists before trying to access it (which will cause an exception.) Is there an easy way to check for a...
4
3639
by: bdockery | last post by:
Access 2007 I have a table with three columns. Country, State, City What I want to do is have a form where the Country, and State, lookups auto-populate when the city lookup is chosen. It...
2
2154
by: querry | last post by:
Hi all, I am trying to change the background color of individual Table Cells using the javascript as follows. function changecolor(e) { var etarg; if (!ee) var ee = window.event; ...
2
1854
by: arawsg | last post by:
im new to sql and ive created a test data base with a test table having 3 input fields i was wondering if it was possible to use a webpage to input data into the database in a specific table ive...
2
3567
by: shalskedar | last post by:
In the Database I need to delete a record from a specific table.. For ex-There is a field called as "Type" contained in the Master table "Type" . I need to build the query criteria in such a way...
0
7120
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6991
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7196
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5456
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4897
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4583
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
649
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
286
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.