473,379 Members | 1,270 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,379 software developers and data experts.

Referring to current record in a form

How can one refer to a field in a current row of a form in order to filter the Row Source of a linked Combo Box?

In each row itemsSubjects.ID, a foreign key, is set. I want to filter the RowSource of a Combo Box so it shows related fields only. The problem is that Subject should point to the value of the related field only.

My attempt is as follows:

SELECT DISTINCT itemsSubsubjects.ID, itemsSubsubjects.Subsubject FROM itemsSubjects INNER JOIN itemsSubsubjects ON itemsSubjects.Area = itemsSubsubjects.Area
WHERE Subject=itemsSubjects.ID
OR Subject Is Null;

Is there an object ( Object.Subject ) that can point to the related record in the form?
Aug 6 '07 #1
5 5099
MikeTheBike
639 Expert 512MB
HI
How can one refer to a field in a current row of a form in order to filter the Row Source of a linked Combo Box?

In each row itemsSubjects.ID, a foreign key, is set. I want to filter the RowSource of a Combo Box so it shows related fields only. The problem is that Subject should point to the value of the related field only.

My attempt is as follows:

SELECT DISTINCT itemsSubsubjects.ID, itemsSubsubjects.Subsubject FROM itemsSubjects INNER JOIN itemsSubsubjects ON itemsSubjects.Area = itemsSubsubjects.Area
WHERE Subject=itemsSubjects.ID
OR Subject Is Null;

Is there an object ( Object.Subject ) that can point to the related record in the form?
Assuming this is a bound form and query is the RowSource for the Comb Control

Then pehaps the query should be somethink like

Expand|Select|Wrap|Line Numbers
  1. SELECT DISTINCT itemsSubsubjects.ID, itemsSubsubjects.Subsubject FROM itemsSubjects INNER JOIN itemsSubsubjects ON itemsSubjects.Area = itemsSubsubjects.Area
  2. WHERE ItemsSubject.ID = [Forms]![YourFormName]![ID]
  3. OR [Forms]![YourFormName]![Subject] Is Null;
??

You will also need Combo.Requery in the form On Curent Event.

MTB
Aug 6 '07 #2
Whenever I requery using this meethod all the Combo boxes are redefined. What I need is that the current record requery only the related combo box
Aug 8 '07 #3
BoxTop
12
SELECT DISTINCT itemsSubsubjects.ID, itemsSubsubjects.Subsubject FROM itemsSubjects INNER JOIN itemsSubsubjects ON itemsSubjects.Area = itemsSubsubjects.Area
WHERE Subject= Forms![NameOfYourForm]![itemsSubjects].Column(0)
OR Subject Is Null;

The column number should be set to the number of you ID column. Column numbers start with 0, so if you ID column is the second one in the list it would be Column(1)
Aug 8 '07 #4
MikeTheBike
639 Expert 512MB
Whenever I requery using this meethod all the Combo boxes are redefined. What I need is that the current record requery only the related combo box
Why do all the Combo Boxes redefine?

They will only redefine if you requery them somewhere!

One thought, do you mean you want the combo box to DISPLAY the record related to the one selected on the form?

MTB
Aug 8 '07 #5
Thank you guys for all the help you're offereing, Let me reexplain the problem

I am writing a school application. I have one table for classes, one for subjects(courses: Maths, english, etc), one for topics( Grammar, spelling, Algebra, etc). One common field between subjects and topics is Area(values can be: language, math, science, etc) and is used to map some topics to related subjects; e.g to restrict algebra to be assigned to, say, English. Or Spelling to Physics)
Now in the form(continuous), I choose the class, then the Subject. What I need next is to choose the topic. The drop down(Combo box) should be filtered and show only related topics (filtered using the common AREA field of the subjects and topics)
I tried many methods. If I refer to the field Forms!<...>!ID, it would be filtered however all the other topics field value disapear, however the values are still in the table. This confused end-users.
What I did is: I placed a text field above the combo box. I do not like this solution, even though it works.
So what do you think?
Aug 9 '07 #6

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

Similar topics

1
by: Tony | last post by:
I have a form in access that has 5 fields for a certain record: 1)Date mailed, 2)Date received, 3)Date completed 4)Foreign Content amount and 5)record number. If the foreign content (FC)is >15% of...
2
by: Tony | last post by:
Hello, I am having difficulty in getting the current record of the current form to show after pressing a command button that takes me to another form. The command button takes me to another...
4
by: DBQueen | last post by:
I have a subform which is in Continuous Forms view. I have added a button to the bottom of the page to move to the next record using the button wizard (result: DoCmd.GoToRecord , , acNext). I...
1
by: Richard Coutts | last post by:
I have a Continuous Form where each record has a button that activates another form that simplifies entering values into the record. The activated form has the equivalent of a "Done" button. I'd...
3
by: Maria | last post by:
Is there another way to delete the current record in a subform from the main form, another subform or a sub-subform other than setting focus on a field in the subform and using run command...
2
by: Rosy | last post by:
I am attempting to use the following code to print a report based on the current record in the form. Users bring up the record with a parameter box and then can make changes to the sub-form on the...
1
by: Randy | last post by:
I have tried the code to attach a button to a form and use the help information on coding, but I can't seem to get it to work. I have a main form called MAIN CLIENT INFO2 There is a subform...
8
by: Zlatko Matić | last post by:
There is a form (single form) and a combobox. I want that current record of the form is adjusted according to selected value in the combobox. Cuurrent record should be the same as the value in the...
1
by: 4004 | last post by:
I would like to open a columnar form (so I can see all the details) from a datasheet form (so I can see what is there) but keep the same recordset and current record. I can do the recordset set...
1
by: Jeff Karli | last post by:
I think I now understand how to use this forum. I hope I am following the rules now. I am a college student working on a database project that requires some VBA coding for the Event Procedures and...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?

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.