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

Filtering a form

I have designed a form(main form) which has a record source that runs subforms. this works perfectly. I also have a macro that is attached to this subform which filters records on a different form. One of my subforms contains personnel IDs and few details. When I click on the ID field the macro runs and opens another form, filtering it by the ID number. This works when the subform is opened independently but when the subform is opened on a record source frame and you try to click on the id field you get an error message that Ms access can't find the subform referred to in a macro.

How can I filter using a code? I tried using DoCmd.penform command and it works, but I fail to come up with code that can pick the id number from the subform and opens the other form filtering it by the same ID. I need help.
Aug 1 '11 #1
6 1456
nico5038
3,080 Expert 2GB
In general when wanting to have two subforms synchronized I use a (hidden) textfield on the main form.
In the first subform I add in the OnCurrent event a line like:
Expand|Select|Wrap|Line Numbers
  1. Parent.txtPersID = Me.PersID
  2.  
This will fill the proper ID, next I link the other subform (just single click to get the LinkageFields property) to this txtPersID and when changing the first subform's row, the other subform will show the related Persons record.

Getting the idea ?

Nic;o)
Aug 1 '11 #2
Nic;

i do get the idea and i know this would work with subforms..but what iam trying to do is to open a new form from a subform not opening another subform. so i dont know if the Parent. expression will work.
Aug 2 '11 #3
nico5038
3,080 Expert 2GB
OK, for referring to fields in a subform you need to use qualificaton like described in http://access.mvps.org/access/forms/frm0031.htm
This, combined with the docmd.openform with a filter, would do the trick.

Nic;o)
Aug 2 '11 #4
NeoPa
32,556 Expert Mod 16PB
Dan,

What Nico has posted covers forms, subforms and their interrelationships well, but if as you say, you are working with a form which is separate from the current form, but invoked by that same current form, then you simply need a reference to that separate form. If the separate form was invoked from code within the current form then it must know the name of that form at least, if it doesn't maintain an object reference to it. Using an object reference is even easier of course, but if only the name is available then Forms({Name}) gives the same reference to the form. From there what you want to reference is down to you (and should be pretty straightforward).
Aug 2 '11 #5
If Text_EmployeeID is the name of the textbox that contains the employee Id in the subform and Frm_Employee_Details is a form that displays the details about an employee, i have used:
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenForm "Frm_Employee_Details", , , "empID=" & Me.Text_EmployeeID.Value
but i get a data type mismatch error 3464.
Aug 2 '11 #6
thanx i managed.... hope you guys enjoy your day
Aug 2 '11 #7

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

Similar topics

3
by: Aionius | last post by:
Good day to all. I have this problem in JavaScript. I have a form (textbox) which accepts a series of numbers in format 9999-9999-9. Now i want to filter all inputs to the textbox. let's say...
0
by: CSDunn | last post by:
Hello, I have a problem with field filtering between an Access 2000 Project form (the application is called CELDT), and the report that shows the results of the filter. Both the form and the...
7
by: Nathan Bloomfield | last post by:
Hi All, I am hoping someone out there will be kind enough to find out where my code is going wrong. The current code is inefficiant but hopefully it will convey the data I require to be...
2
by: Aravind | last post by:
Hi folks. I have a form, frmHistory, which has 4 command buttons: Sort Title (cmdSortTitle), Sort Name (cmdSortName), Due Today (cmdDueToday), and Due List (cmdDueList). Sort Title and Sort...
1
by: Aravind | last post by:
Hi folks. My database project has the following: -------------------------------------------------------------------------------- tables: Member: MemName, MemNo , MemType, CourseFaculty...
2
by: Sean | last post by:
Greetings all, I am attempting to make a form that will filter through several tables that (I believe) have refretial integrity. I am pulling data from several tables into the form and i would...
4
by: Dave | last post by:
I am having difficulty filtering a form as the user types in a onchange event here is my code strFilter = cboCriteria.Value & " LIKE '" & Me!txtCriteria.text & "*" & "'" If Len(strFilter ) 0...
12
by: hlebforprimeminister | last post by:
Hi I want to filter records on a continuous form(FRM_SUPPT) by one of the fields, SW_ID. FRM_SUPPT has a text box ( bound to SW_ID) and two drop-down lists that are bound also. The three...
4
by: novoselent | last post by:
This seems like it should be an easy thing, but I think I'm missing something simple here...or I'm just going about it all wrong... Using Access 2003 I have a form that lists vehicle service...
23
by: David Davis | last post by:
Hello, Ran into a snag while building my database. I have several forms but lets work with two for right now; Form1 and Form2 both have the same fields but use by two different users but both are...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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...

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.