473,761 Members | 4,407 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need to include Field List In Form, help!

10 New Member
Hey guys,
I have two main questions
First off (pictures are kind of blurry)
I have this table
http://i197.photobucket.com/albums/a.../DiscTable.jpg

And thats my database I use my Form on

I created a search form:
http://i197.photobucket.com/albums/a...SearchForm.jpg

Then created a listbox, selected a "field List" and got all of the header values from my table..
so its a box with every header from the table so if you look its like this:
http://i197.photobucket.com/albums/a...earchForm2.jpg


As you see, I turned on the multi-seclect feature to simple so I can select more than one

So from the original discform without the field list
I was able to select one or more sizes, click search then it will update the subform/table and show only those sizes,

so heres my two questions:
for the field list first of all, I dont want the first 2 things which are part #, size, just those pressures, so I don't need thsoe first two columns how do I make that show?

second:
heres my code from the search button,
that works with the size list,
but I need to integrate this Field list into the search button so it will also update, oh yeah and if it says NA under a pressures, insteaf of a number, I dont want that to show as a search result
so heres the code: what do I need to add to make this work?
code:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Option Compare Database
  3. Option Explicit
  4.  
  5. Private Sub btnClear_Click()
  6. Dim intIndex As Integer
  7.  
  8. ' Clear all search items
  9.  
  10.  
  11. ' De-select each item in Color List (multiselect list)
  12. For intIndex = 0 To Me.SizeList.ListCount - 1
  13. Me.SizeList.Selected(intIndex) = False
  14. Next
  15.  
  16. End Sub
  17.  
  18. Private Sub btnSearch_Click()
  19.  
  20. ' Update the record source
  21. Me.DiscForm.Form.RecordSource = "SELECT * FROM DiscTable " & BuildFilter
  22.  
  23. ' Requery the subform
  24. Me.DiscForm.Requery
  25. End Sub
  26.  
  27.  
  28. Private Sub Form_Load()
  29.  
  30. ' Clear the search form
  31. btnClear_Click
  32.  
  33. End Sub
  34.  
  35. Private Function BuildFilter() As Variant
  36. Dim varWhere As Variant
  37. Dim varSize As Variant
  38. Dim varItem As Variant
  39. Dim intIndex As Integer
  40.  
  41. varWhere = Null ' Main filter
  42. varSize = Null ' Subfilter used for colors
  43.  
  44.  
  45.  
  46. ' Check for Colors in multiselect list
  47. For Each varItem In Me.SizeList.ItemsSelected
  48. varSize = varSize & "[Size] = """ & _
  49. Me.SizeList.ItemData(varItem) & """ OR "
  50.  
  51. Next
  52.  
  53. ' Test to see if we have subfilter for colors...
  54. If IsNull(varSize) Then
  55. ' do nothing
  56. Else
  57. ' strip off last "OR" in the filter
  58. If Right(varSize, 4) = " OR " Then
  59. varSize = Left(varSize, Len(varSize) - 4)
  60. End If
  61.  
  62. ' Add some parentheses around the subfilter
  63. varWhere = varWhere & "( " & varSize & " )"
  64. End If
  65.  
  66. ' Check if there is a filter to return...
  67. If IsNull(varWhere) Then
  68. varWhere = ""
  69. Else
  70. varWhere = "WHERE " & varWhere
  71.  
  72. ' strip off last "AND" in the filter
  73. If Right(varWhere, 5) = " AND " Then
  74. varWhere = Left(varWhere, Len(varWhere) - 5)
  75. End If
  76. End If
  77.  
  78. BuildFilter = varWhere
  79.  
  80. End Function
  81.  
Someone please help me out with this, I would appreaciate it.
Jun 14 '07 #1
1 2463
MMcCarthy
14,534 Recognized Expert Moderator MVP
Then created a listbox, selected a "field List" and got all of the header values from my table..
so its a box with every header from the table so if you look its like this:
http://i197.photobucket.com/albums/a...earchForm2.jpg
I don't use the field list setting very often but I'm not aware of any way of restricting the list. However, you can also base the list on a query so create a query with just the fields you want to show in the list and set the query as the lists row source. This should solve that problem.

As for building the subforms recordsource, try the following:

Expand|Select|Wrap|Line Numbers
  1. Private Sub btnSearch_Click
  2.     ' Update the record source
  3.     Me.DiscForm.Form.RecordSource "SELECT " & BuildSelect & " FROM DiscTable " & BuildFilter
  4.     ' Requery the subform
  5.     Me.DiscForm.Requery
  6. End Sub 
  7.  
  8. Private Function BuildSelect() As String
  9. Dim strSelect As String
  10. Dim varItem As Variant
  11.  
  12.     For Each varItem In Me.PressureList.ItemsSelected
  13.         strSelect = strSelect & Me.PressureList.ItemData(varItem) & ", " 
  14.     Next
  15.  
  16.     ' Remove the last comma
  17.     strSelect = Left(strSelect, Len(strSelect) - 2)
  18.  
  19.     BuildSelect = strSelect
  20.  
  21. End Function
  22.  
  23. Private Function BuildFilter() As String
  24. Dim strWhere As String
  25. Dim strPressure As String
  26. Dim varItem As Variant
  27.  
  28.     strWhere = "WHERE ("
  29.  
  30.     ' Check for Colors in multiselect list
  31.     For Each varItem In Me.SizeList.ItemsSelected
  32.         strWhere = strWhere & "[Size] = """ & _
  33.         Me.SizeList.ItemData(varItem) & """ OR "
  34.     Next
  35.  
  36.     ' set pressure criteria
  37.     For Each varItem In Me.PressureList.ItemsSelected
  38.         strPressure = strPressure & Me.PressureList.ItemData(varItem) & " <> 'N/A' AND " 
  39.     Next
  40.  
  41.     ' Remove last AND
  42.     strPressure = Left(strPressure, Len(strPressure) - 5)
  43.  
  44.     ' Test to see if we have subfilter for colors...
  45.     If strWhere = "WHERE (" Then
  46.         strWhere = strPressure & ")"
  47.     Else
  48.         ' strip off last "OR" in the filter
  49.         strWhere = Left(strWhere, Len(strWhere) - 4)
  50.         strWhere = strWhere & ") AND (" & strPressure & ")"
  51.     End If
  52.  
  53.     BuildFilter = strWhere
  54.  
  55. End Function
  56.  
Jun 14 '07 #2

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

Similar topics

2
2937
by: Mike Button | last post by:
Hello all, I am really really desperate on what I should do, and I am asking for help from anyone in this newsgroup, here's the situation: I am creating a form that is being run on a server where there is no scripts allowed running (the software is from Opentext called Livelink)- therefore I need javascript to do the tasks listed below: 1. validate the form - this has been completed 2. pop up another window that will go ahead and...
19
4107
by: James Fortune | last post by:
I have a lot of respect for David Fenton and Allen Browne, but I don't understand why people who know how to write code to completely replace a front end do not write something that will automate the code that implements managing unbound controls on forms given the superior performance of unbound controls in a client/server environment. I can easily understand a newbie using bound controls or someone with a tight deadline. I guess I need...
3
10663
by: google | last post by:
I have a database with four table. In one of the tables, I use about five lookup fields to get populate their dropdown list. I have read that lookup fields are really bad and may cause problems that are hard to find. The main problem I am having right now is that I have a report that is sorted by one of these lookup fields and it only displays the record's ID number. When I add the source table to the query it makes several records...
2
2691
by: Uninvisible | last post by:
I have put together a db for a law firm to keep track of counterfeit activities. There are four parent tables: tblContact tblTransaction tblAction tblFile I have created a form, frmNewMatter, for adding new records to the db. The form is based on tblFile and has a subform based on tblContact,
11
2804
by: my-wings | last post by:
I think I've painted myself into a corner, and I'm hoping someone can help me out. I have a table of books (tblBooks), which includes a field (strPubName) for Publisher Name and another field (strPubCity) for Publisher City. These two fields have a many-to-one relationship with tables, (tlkpPubName and tlkpPubCity) respectively. The lookup tables only have one field (strPubName and strPubCity), which is their primary key. I also have...
2
1529
by: CW | last post by:
In an earlier thread, I was asking for help on "Invalid attempt to FieldCount when reader is closed" error when I was using a dataset rather than a datareader to bind to a datagrid. After playing around with it, I found out that the error was caused by template columns. Once I remove template columns, everything worked fine. Here are my scenarios and I would appreciate input on it. My datagrid is bound to a orderlines table. In the...
0
2259
by: ward | last post by:
Greetings. Ok, I admit it, I bit off a bit more than I can chew. I need to complete this "Generate Report" page for my employer and I'm a little over my head. I could use some additional assistance. I say additional because I've already had help which is greatly appreciated. I do try to take the time and understand the provided script in hopes on not having to trouble others on those. But here it goes...
9
2198
by: MrHelpMe | last post by:
Hello again experts, I have successfully pulled data from an LDAP server and now what I want to do is drop the data into a database table. The following is my code that will insert the data but that has problems. FullName=Request.Form("Name") Email=Request.Form("Email") GivenName=Request.Form("GivenName")
2
3156
by: sorobor | last post by:
dear sir .. i am using cakephp freamwork ..By the way i m begener in php and javascript .. My probs r bellow I made a javascript calender ..there is a close button ..when i press close button then the calender gone actually i want if i click outside off the calender then it should me removed ..How kan i do this ... Pls inform me as early as possible .. I am waiting for ur quick replay ...Here i attached the source code .... <!DOCTYPE...
0
9345
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10115
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9957
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9905
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9775
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8780
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7332
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6609
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
3
2752
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.