473,770 Members | 4,552 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Form Filters or Rebuild SQL Statement as Recordsource?

HK
I have an inventory form designed in continuous format so that users
can edit quantity on hand information. I have numerous filters set up
because the inventory table holds sever hundred thousand records.
Should I be using a form filter instead of the following code?

I use the following function to change the forms record source.
UpdateView is called anytime a user makes changes to the checkboxes,
radio buttons, etc.

Public Function UpdateView()

Dim strSQL As String
Dim strExcludeZero As String
Dim strOrderBy As String
Dim strItem As String
Dim strCat As String

If chkExcludeZero = True Then
strExcludeZero = "and bal_qty <> 0 "
Else
strExcludeZero = ""
End If

If chkLimitCat = True Then
strCat = "and ccategory ='" & cboCat.Value & "'"
Else
strCat = ""
End If

If optSearch = 1 Then
strItem = "item_loc ='" & Me.cboItemLocat ion.Column(0) & "'"
ElseIf optSearch = 2 Then
If Nz(txtSearch.Va lue, "") = "" Then
MsgBox ("You must search for something!!")
Exit Function
End If
strSearch = txtSearch.Value
strItem = "item_desc LIKE '*" & strSearch & "*'"
End If

If optOrderBy = 0 Then
strOrderBy = "bal_qty DESC"
ElseIf optOrderBy = 1 Then
strOrderBy = "item_cd ASC"
ElseIf optOrderBy = 2 Then
strOrderBy = "item_desc ASC"
End If

strSQL = "Select ccategory, item_cd, item_desc, bal_qty, reord_lvl,
item_loc FROM xmsalinv1 WHERE " + strItem + " " + strExcludeZero + " "
+ strCat + " ORDER by " + strOrderBy + ";"

Me.RecordSource = strSQL
Me.Requery

Feb 20 '06 #1
0 1094

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
7733
by: Louis | last post by:
I'm running the following code but it keeps failing because Select isn't a part of the action query method: Private Sub Command2_Click() Dim SQLStr As String SQLStr = "SELECT Request.RequestID, Request.ReqName, Request.ReqDesc FROM Request" DoCmd.RunSQL SQLStr 'Debug.Print SQLStr
3
2902
by: RC | last post by:
I can't quite grasp the concept of creating custom reports depending upon what options a user picks on a Form. For example, the user clicks on a "Print Reports" button and a Form pops up. On the Form the user can choose to get a report that shows the Box Numbers that are at Warehouse A, Warehouse B or Warehouse C. and then click on the Print Preview button and get a report showing only the Box Numbers in whichever warehouse was...
25
10265
by: Lyn | last post by:
Hi, I am working on a genealogy form. The only table (so far) lists everybody in the family, one record per person. Each record has an autonum ID. The parent form (frmMainForm) displays the data in each record, which includes the ID of the father and the mother (who also have records in the table). One record per form. I have a Tab Control in the form, and in one of the tabs I have a subform (sfmSiblings) in which I wish to list...
1
2022
by: Steve Miles | last post by:
I've got a form with a combo box and begin/end dates. When any of the three are changed I set a subform's recordsource so the records returned are filtered based on the three fields. The syntax I'm using is: Me.{subform-name}.Form.RecordSource = "Select * from tbl..." ....including the three fields in the SQL Where clause. This method works well, but mysteriously stops returning any rows once in a while. I can hard-code the SQL to...
10
4035
by: glenn354 | last post by:
I have a form I would like to use in front of several queries. For example, I want to use frmA but only looking at the records retrieved by qryX. Then I want to use frmA again, but only looking at the records retrieved by qryY. Then be able to reuse frmA to view records from qryZ. My reasoning is that if the form changes, I don't have to manipulate multiple forms. There will be approximately 20 such queries. Has anyone done something...
2
1500
by: Jeff | last post by:
Hi, I am trying to use vb code to set the filter on a form so that only people with a common property can see each other on a form when they open it (like if they are in the same department). But I cannot seam to get the filters to work correctly and most of the time I'm just getting no records to display. Could someone lead me onto the right path?
2
2363
by: KashMarsh | last post by:
Access 2003 I need to have a user filter records on a linked, continuous form and then I want to run various reports/queries from this recordset the user created. I only need to see the PK values they filtered for. On the form, there could be 10 controls displaying that the user filters/sorts in whatever way they want to, but I only need to extract the control holding the PK values as a "recordset" so that I can use this to create a...
2
8177
by: Robert | last post by:
I am trying to give the user dynamic search capabilities to select almost any record in the database from criteria they select. Everything seems to work except when I open the display form to display the data to the user. If that form is already open, how do I make it refresh its data source and display the new data. Here is what I am doing. >From a text entry form, I create an SQL query dymanically and alter the sql statement of an...
2
946
by: fstenoughsnoopy | last post by:
I have a customer order database and I need to pull a customers information, ie first name, last name, address, city, state, zip, phone, etc, into the oder table. i don't know how to go about making this work...
0
9602
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9439
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
10237
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...
1
7431
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
6690
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();...
0
5467
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3987
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3589
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2832
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.