473,407 Members | 2,306 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

SQL Query in a form

I have a form that allows examiners to be assigned to a particular centre.
So for example i have 10 examiners who all examine different subjects and i have 5 centres one of which is doing an exam in maths. What i want to do have a combo box on the Centre form that only shows examiners that can actually mark that subject(Subject_Ref_Code),

I have SQL that works

Expand|Select|Wrap|Line Numbers
  1. SELECT tblExaminer.Examiner_Number,
  2.        tblExaminer.Examiner_Name,
  3.        tblExaminer.Subject_Ref_Code
  4. FROM tblExaminer
  5. WHERE (((tblExaminer.Subject_Ref_Code)=[forms]![frmCentre]![Subject_Ref_Code]));
But this only runs once when i enter the form. Is there a way i can make this code run again when a different Subject Ref Code is selected so only relevant examiners are found?


thanks

Mark
Feb 12 '07 #1
7 1610
NeoPa
32,556 Expert Mod 16PB
Call a .Requery of the object that this SQL refers to after the Subject Ref Code has been selected.
Feb 12 '07 #2
Call a .Requery of the object that this SQL refers to after the Subject Ref Code has been selected.
spot on cheers.
Feb 13 '07 #3
NeoPa
32,556 Expert Mod 16PB
No problem. Glad it's working for you :)
Feb 13 '07 #4
working well and this next bit seems like such a minor problem but the combo box always says #name? in it and no matter what i do i cant get rid of it!!

im sure its very simple...
Feb 14 '07 #5
NeoPa
32,556 Expert Mod 16PB
So the .Requery works ok, but the results are never right?
Is the [Subject_Ref_Code] control empty when this is seen?
Are you still using the SQL posted in post #1 as the RowSource?
Feb 14 '07 #6
So the .Requery works ok, but the results are never right?
Is the [Subject_Ref_Code] control empty when this is seen?
Are you still using the SQL posted in post #1 as the RowSource?
Sorry didnt explain myself well. You code is spot on and when you click on the combo box the right records are there. The problem is that when the form is loaded it says #name in the combo box and i cant get rid of it!
Feb 15 '07 #7
NeoPa
32,556 Expert Mod 16PB
Expand|Select|Wrap|Line Numbers
  1. SELECT tblExaminer.Examiner_Number,
  2.        tblExaminer.Examiner_Name,
  3.        tblExaminer.Subject_Ref_Code
  4. FROM tblExaminer
  5. WHERE (((tblExaminer.Subject_Ref_Code)=[forms]![frmCentre]![Subject_Ref_Code]));
Oh right.
That's because your query has a filter on the value in the [Subject_Ref_Code]. This probably has no value when the form first opens. Try adding the SQL to the ComboBox in the AfterUpdate event procedure of the [Subject_Ref_Code] control. The form would start off with nothing in there and then add it, or take it away, in the procedure depending on there being a value in the field.
Does this make sense?
Feb 15 '07 #8

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

Similar topics

3
by: Harvey | last post by:
Hi, I try to write an asp query form that lets client search any text-string and display all pages in my web server that contain the text. I have IIS 6.0 on a server 2003. The MSDN site says...
3
by: MX1 | last post by:
I have a query written in MS Access that has a few calculated fields. Is it possible to refer to that query in a form field. I'd like the form field to show the sum of one of the columns from the...
3
by: Steve | last post by:
Form FrmRestock's recordsource is QryFrmRestock. The TransactionDate field's criteria is set ats: Forms!FrmRestock!LastXDays. LastXDays on the form is a combobox where the selections are 30, 60...
1
by: Nicolae Fieraru | last post by:
Hi All, I want to find if there is a different way than the way I am working now. Lets say I have a table, tblCustomers containing address details. I want a report with all the customers from...
6
by: Brian | last post by:
Hello, Basically, I'm running a query on a form's activation, and I'd like to have the results of the query be placed into other fields on the same form automatically. Does anybody know how...
13
by: Lee | last post by:
Hello All, First of all I would like to say thank you for all of the help I have received here. I have been teaching myself Access for about 4 years now and I've always been able to find a...
3
by: rhobson2 | last post by:
Hello, I wrote a database applicaiton using Access XP (2002) and everything has been working good for the client until they purchased a couple of new computers with Access 2003. The meetings...
1
by: bgreenspan | last post by:
Hi Everyone, I'm back for some more expert help. Here's what I am doing and what I tried. My database has entries with Contract Names and Expiry Dates, among other fields. I have a form...
3
by: pbd22 | last post by:
Hi. I need some help with structuring my query strings. I have a form with a search bar and some links. Each link is a search type (such as "community"). The HREF for the link's anchor looks...
2
by: lindabaldwin | last post by:
Hello everyone, I am fairly new to VBA. I have a worksheet in Excel, named "Data Sheet" from which I am trying to query data. This worksheet contains the following data: unit (column A), date...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...
0
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...

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.