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.

Trying to open subform with Filter value

Hi,

When a user double clicks on my last_name field, I want a subform to open. The subform should only display the filtered last name data but I get all records displayed instead. Not sure what I am doing wrong - can someone please help?

Below is my code:

Expand|Select|Wrap|Line Numbers
  1. Private Sub last_name_DblClick(Cancel As Integer)
  2.  
  3. last_name_Trim = Trim(Me.last_name)
  4.  
  5. DoCmd.OpenForm "subform - employee drill down east", acNormal, , "last_name ='" & last_name_trim & "'", acFormReadOnly, acWindowNormal
  6.  
  7. End Sub
May 19 '14 #1
8 1621
jimatqsi
1,271 Expert 1GB
mays0515,
Welcome to Bytes.com.

Are you opening this form anywhere else? Is it possible another event is opening the form without the where clause? Have you tried setting a debug stop at line 5 and verifying the content of last_name_trim?

Also,
1. If last_name_Trim is a local variable it should declared locally. If it's a global variable, it should be identified with a lower case 'g' or some other obvious prefix. We are left to assume it is a string.
2. You should include some error handling to display or log an error message.
3. You are not opening a subform, in spite of the word 'subform' in the name of the form. A subform is a form positioned on a form, not a form opened by a form's code.

Jim
May 19 '14 #2
Hi,

Yes I have tried setting a debug stop at line 5 and verified the last name trim. also, the form is not being opened anywhere else.
1. I have tried running with and without last_name_trim (used me.last_name directly in the openform but had the same results)
2. Hmmm I do not get any error messages - the form does get displayed - would I still need to add some sort of error handling to figure out my issue?
3. You are right - it is just another form being opened - sorry about that

Any other ideas?

Thanks so much for your help!
May 19 '14 #3
jimatqsi
1,271 Expert 1GB
Is the recordsource a table or query? It would be interesting to make sure it is a query and add that criteria to the query, just to verify the results are actually achieved outside of the form.

Just kind of throwing darts now, I don't see any problem. Oh, what is the value of the last name you tried? Any special characters involved?

Jim
May 19 '14 #4
jimatqsi
1,271 Expert 1GB
About error handling, you need to make that a habit. It may be there are no errors being encountered in this case and so you're not missing anything. But it is an important habit to establish.

Jim
May 19 '14 #5
I think i found the problem - the "subform - employee drill down east" is a form and within this form, i have a subform that is linked to a query. When i create a "Stand alone" form directly linked to the query, my where conidition works in the OpenForm works. But now, instead of datasheet view being displayed on the double click of the last name field, I get form view - how do i change it to datasheet view?
May 19 '14 #6
jimatqsi
1,271 Expert 1GB
You can change the default view of the form in the Format tab of the form properties. Will that do?

Jim
May 19 '14 #7
that worked - thanks so much for your help!! Really appreciate it!
May 19 '14 #8
jimatqsi
1,271 Expert 1GB
Excellent! So glad to help.
May 19 '14 #9

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

Similar topics

1
by: Annette Massie | last post by:
I have a form (frmMainForm) that has a tab control (frmTab). This tab control has 4 pages. Each page has a subform on it. I am in the first tab's subform and in a listbox. I want to double click...
0
by: JC Voon | last post by:
Hi All: I have a problem when trying to set the value of the structure member using reflaction,here is the code: Public Const MemberAccess As BindingFlags = BindingFlags.Public Or...
9
by: natwong | last post by:
Hi All, I'm a newbie in terms of Access and some of its functionality . I've been stuck on this problem for a couple days, even after searching the Web, etc. Currently I have five combo boxes...
1
by: maciejfr | last post by:
Hello everyone, My problem is updating Subform filter by onchange event in one of main form field I've got following: Me!.Form.Filter = " = "" N "" OR ( = ""T"" AND notanr = " & Me!nrnoty...
4
by: mrubel99 | last post by:
I have a subform built into a form in Access 2007. I would like the user to be able to filter the subform using their own criteria by right clicking the column header in the subform. Once the user...
0
by: diogenes | last post by:
"Rick Brandt" <rickbrandt2@hotmail.comwrote in news:bPnKj.456$%41.325 @nlpi064.nbdc.sbc.com: I used this approach, and it works a treat! ID In(SELECT Order_ID FROM orderitems WHERE NAME =...
4
WyvsEyeView
by: WyvsEyeView | last post by:
I am doing the very standard thing of filtering the contents of one combo box based on another combo box. I've done it many times, but always on a main form. Now I'm trying to do it on a datasheet...
1
by: rwalle | last post by:
Hi : I have done a form with a subform inside to filter customers, the form have a Text box where user write down a name then I take this text box data as a criteria to the query wich subform...
1
by: Mary meer | last post by:
i am trying to switch array value but i get this error message: Undefined offset 2 $at=array( array('Title:','title',2,10), array('First Name:','fname',2,10 ), ...
18
by: Becker | last post by:
I have a combo box with a list a values that when picked the form should filter to show the corresponding record from a table. Everything works fine when I open up the form by itself. However, I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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.