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

Home Posts Topics Members FAQ

Filtering form fields that are bound

24 New Member
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 together are joint primary keys. I need to be able to view data and enter it on this form.

Now the default value of the SW_ID textbox is from a textbox on the previous form(FRM_SOFTWARE).

On FRM_SOFTWARE form, when you click on a button it opens up FRM_SUPPT and the default value pops up so i can enter new data.

However it also shows all the records entered in this form with ones with a different value for SW_ID.

I want to be able to enter data while at the same time being able to see all records that have the same value of SW_ID, but I do NOT want to be able to see records with a different value.

Help would be greatly appreciated

Thanks
HlebforPM
Aug 9 '07 #1
12 2836
puppydogbuddy
1,923 Recognized Expert Top Contributor
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 together are joint primary keys. I need to be able to view data and enter it on this form.

Now the default value of the SW_ID textbox is from a textbox on the previous form(FRM_SOFTWARE).

On FRM_SOFTWARE form, when you click on a button it opens up FRM_SUPPT and the default value pops up so i can enter new data.

However it also shows all the records entered in this form with ones with a different value for SW_ID.

I want to be able to enter data while at the same time being able to see all records that have the same value of SW_ID, but I do NOT want to be able to see records with a different value.

Help would be greatly appreciated

Thanks
HlebforPM
Try this code in the open event for your form:
Expand|Select|Wrap|Line Numbers
  1. Dim strFilter As String
  2.  
  3. 'assuming that SW_ID is numeric data type
  4. strFilter = "[SW_ID] = " & Me![SW_ID]       
  5.  
  6. Me.Filter = strFilter
  7. Me.FilterOn= True
Aug 9 '07 #2
MikeTheBike
639 Recognized Expert Contributor
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 together are joint primary keys. I need to be able to view data and enter it on this form.

Now the default value of the SW_ID textbox is from a textbox on the previous form(FRM_SOFTWARE).

On FRM_SOFTWARE form, when you click on a button it opens up FRM_SUPPT and the default value pops up so i can enter new data.

However it also shows all the records entered in this form with ones with a different value for SW_ID.

I want to be able to enter data while at the same time being able to see all records that have the same value of SW_ID, but I do NOT want to be able to see records with a different value.

Help would be greatly appreciated

Thanks
HlebforPM
Hi

How about

Expand|Select|Wrap|Line Numbers
  1. Dim stDocName As String
  2. Dim stLinkCriteria As String
  3.  
  4. stLinkCriteria = "[SW_ID] = " & textboxSW_ID
  5.  
  6. stDocName = "FRM_SUPPT"
  7. DoCmd.OpenForm stDocName, , , stLinkCriteria 
??

Just a thought, but you do not give any clues as to how you are opening the second form!

MTB
Aug 9 '07 #3
hlebforprimeminister
24 New Member
Thanks for the reply.

I've tried it but it doesn't seem to be working, all the entries with different values of SW_ID still keep popping up.

I'm not sure if I am doing it right. The text box that is bound to SW_ID is called txtSwId so I typed in:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Open(Cancel As Integer)
  2. Dim strFilter As String
  3.  
  4. 'assuming that SW_ID is numeric data type
  5. strFilter = "[SW_ID] = " & Me![SW_ID]
  6.  
  7. Me.Filter = strFilter
  8. Me.FilterOn = True
  9. End Sub
  10.  
I tried various combinations by replacing SW_ID with txtSwId because I wasn't sure whethter they were referring to the text box or not
Aug 9 '07 #4
hlebforprimeminister
24 New Member
Hi

How about


Code: ( text )
Dim stDocName As String
Dim stLinkCriteria As String

stLinkCriteria = "[SW_ID] = " & textboxSW_ID

stDocName = "FRM_SUPPT"
DoCmd.OpenForm stDocName, , , stLinkCriteria


??

Just a thought, but you do not give any clues as to how you are opening the second form!

MTB
I have a button that opens the second form. I just used the button wizard. The code behind the button that opens it is:

Expand|Select|Wrap|Line Numbers
  1.     Dim stDocName As String
  2.     Dim stLinkCriteria As String
  3.  
  4.     stDocName = "FRM_SUPPORT"
  5.     DoCmd.OpenForm stDocName, , , stLinkCriteria
  6.  
The first form remains open when I open up FRM_SUPPT.
Aug 9 '07 #5
puppydogbuddy
1,923 Recognized Expert Top Contributor
Thanks for the reply.

I've tried it but it doesn't seem to be working, all the entries with different values of SW_ID still keep popping up.

I'm not sure if I am doing it right. The text box that is bound to SW_ID is called txtSwId so I typed in:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Open(Cancel As Integer)
  2. Dim strFilter As String
  3.  
  4. 'assuming that SW_ID is numeric data type
  5. strFilter = "[SW_ID] = " & Me![SW_ID]
  6.  
  7. Me.Filter = strFilter
  8. Me.FilterOn = True
  9. End Sub
  10.  
I tried various combinations by replacing SW_ID with txtSwId because I wasn't sure whethter they were referring to the text box or not

Change the line below. Replace YourForm with actual name of form that is passing the ID field value, Also, is SW_ID a numeric data type or a text data type?

strFilter = "[SW_ID] = " & Form!YourForm![txtSwId]
Aug 9 '07 #6
hlebforprimeminister
24 New Member
Change the line below. Replace YourForm with actual name of form that is passing the ID field value, Also, is SW_ID a numeric data type or a text data type?

strFilter = "[SW_ID] = " & Form!YourForm![txtSwId]
Its numeric, an autonumber.

I replaced the line but it said "cannot find field FRM_SOFTWARE" when i tried to open the form
Aug 9 '07 #7
puppydogbuddy
1,923 Recognized Expert Top Contributor
Its numeric, an autonumber.

I replaced the line but it said "cannot find field FRM_SOFTWARE" when i tried to open the form
FRM_Software has to remain open until the ID is passed. Close FRM_Software on the last line of your open event for the form you opened.
Aug 9 '07 #8
MikeTheBike
639 Recognized Expert Contributor
I have a button that opens the second form. I just used the button wizard. The code behind the button that opens it is:


Expand|Select|Wrap|Line Numbers
  1. Dim stDocName As String
  2.     Dim stLinkCriteria As String
  3.  
  4.     stDocName = "FRM_SUPPORT"
  5.     DoCmd.OpenForm stDocName, , , stLinkCriteria
.
If you had used the "Find specifid record", or whatever the option is in the wizard, it would have generated the code (or similar) that I posted.

??

MTB
Aug 9 '07 #9
hlebforprimeminister
24 New Member
FRM_Software has to remain open until the ID is passed. Close FRM_Software on the last line of your open event for the form you opened.
Sorry for my unclear posts.

The form does remain open (I need it to). Passing the ID is not the problem, that works fine. I have done that part. It passes it and I can make as many entries as I want with SW_ID being kept the same as it takes the value from the other form fine.

It's a continuous form and as well as allowing me to make entries (which works fine) it shows me all the records that are in place, whereas I just want to be able to the see the ones I put in and any previous ones with the same SW_ID.

It has two combo boxes and the text field with SW_ID in it (which i will hide when its done).

At the moment when i open it it has several entries like this (sorry couldn't do proper diagram):

SW_ID= 1 STF_ID - 1 SUPPT_ID - 1
SW_ID= 1 STF_ID - 1 SUPPT_ID - 2
SW_ID= 2 STF_ID - 2 SUPPT_ID - 1
SW_ID= 3 STF_ID - 1 SUPPT_ID - 1

And if I open it with SW_ID being passed through as "3" it would have all the above plus a line allowing me to put in a STF_ID and SUPPT_ID for SW_ID = 3

It functions fine, but when I have thousands of values for SW_ID, I just want it to show the SW_ID for the particular one I want. So I can see what's already there for the particular SW_ID before i make a entry and not have to thousands of records on the form.

Thanks
Hleb
Aug 9 '07 #10
puppydogbuddy
1,923 Recognized Expert Top Contributor
Sorry for my unclear posts.

The form does remain open (I need it to). Passing the ID is not the problem, that works fine. I have done that part. It passes it and I can make as many entries as I want with SW_ID being kept the same as it takes the value from the other form fine.

It's a continuous form and as well as allowing me to make entries (which works fine) it shows me all the records that are in place, whereas I just want to be able to the see the ones I put in and any previous ones with the same SW_ID.

It has two combo boxes and the text field with SW_ID in it (which i will hide when its done).

At the moment when i open it it has several entries like this (sorry couldn't do proper diagram):

SW_ID= 1 STF_ID - 1 SUPPT_ID - 1
SW_ID= 1 STF_ID - 1 SUPPT_ID - 2
SW_ID= 2 STF_ID - 2 SUPPT_ID - 1
SW_ID= 3 STF_ID - 1 SUPPT_ID - 1

And if I open it with SW_ID being passed through as "3" it would have all the above plus a line allowing me to put in a STF_ID and SUPPT_ID for SW_ID = 3

It functions fine, but when I have thousands of values for SW_ID, I just want it to show the SW_ID for the particular one I want. So I can see what's already there for the particular SW_ID before i make a entry and not have to thousands of records on the form.

Thanks
Hleb

So if I understand your example correctly, you want to see only SW_ID's = 3 in this particular case. If that is the case, the filter I gave you should work. Don't understand why it is not working. However, there is more than one way to skin a cat. Another way you could do it is to declare your filter in the line preceding the open form command, and use the OpenForm command to filter the form that is to be opened, as is shown below. I think FRM_SWID was the name of the form you were opening, but I don't remember for sure.

Dim strFilter As String

'assumes that the hidden textbox is on FRM_SUPPT and that filter is used in the OpenForm command.
Expand|Select|Wrap|Line Numbers
  1. strFilter = "[SW_ID] = " & Me!txtSwid
  2.  
  3. DoCmd.OpenForm "FRM_SWID" , acViewNormal , strFilter
Aug 9 '07 #11
hlebforprimeminister
24 New Member
Hi thanks for the help but i still can't get it to work.

This code is in the form FRM_SOFTWARE

Expand|Select|Wrap|Line Numbers
  1. Dim stDocName As String
  2. Dim stLinkCriteria As String
  3.  
  4.  
  5. stDocName = "FRM_SUPPT"
  6. DoCmd.OpenForm stDocName, , , stLinkCriteria
  7.  
I need the data on FRM_SUPPT filtered by SW_ID

So i tried:

Expand|Select|Wrap|Line Numbers
  1. Dim stDocName As String
  2. Dim stLinkCriteria As String
  3. Dim strFilter As String   
  4.  
  5. strFilter = "[SW_ID] = " & Me!txtSwid
  6.  
  7. stDocName = "FRM_SUPPT"
  8. DoCmd.OpenForm stDocName, , , stLinkCriteria, strFilter
  9.  
  10.  
Thanks
Aug 10 '07 #12
hlebforprimeminister
24 New Member
Oh no, I messed it up.

It works perfectly.

Thank you very much puppydog!

Hleb
Aug 10 '07 #13

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

Similar topics

3
by: Jason | last post by:
I am trying to filter records in a primary form based on records in related tables. The data in the related tables is being displayed in the primary form through subforms. To be more specific, I...
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...
14
by: Abhi | last post by:
FYI: This message is for the benefit of MS Access Community. I found that this prblem has been encounterd by many but there is hardly any place where a complete solution is posted. So I thought...
0
by: Patrick | last post by:
I'm working on a contact management application, and need a hand with one aspect... Here's what I want to create: ------------------------------------ A form split into two parts. There is a...
13
by: PW | last post by:
Hi, This is bizarre. I've check and rechecked the spelling, cut and paste the name of the form (when trying to rename the form) and the control yet I still get a parameter prompt when the form...
2
NeoPa
by: NeoPa | last post by:
CHAPTER 1 - TABLE OF CONTENTS (Including attached database) CHAPTER 2 - INTRODUCTION CHAPTER 3 - TABLE LAYOUT CHAPTER 4 - FORM LAYOUT CHAPTER 5 - FORM MODULE CHAPTER 6 - CODE DISCUSSION (FILTER...
0
by: Yarik | last post by:
Hello, Here is a sample (and very simple) code that binds an Access 2003 form to a fabricated ADO recordset: ' Create recordset... Dim rs As ADODB.Recordset: Set rs = New ADODB.Recordset '...
5
by: RHooper | last post by:
Hi, I'm new to Access, so I apologize if this question is trivial. I am trying to set-up a quick filter for users to define on a form bound to a table. I have a combo box called...
2
by: =?Utf-8?B?anAybXNmdA==?= | last post by:
I've got a ListBox on my form with lots of data in it (14000 entries). I have to put a search field on the form. As text is entered into the search field, I want the ListBox to remove entries...
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
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
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.