I am running Access 2010 and have an understanding of VBA Code, but not much coding experience. I would like to know if there is any way of running a Multiple Items Form off a Stander Form. To explain, I have a main form for my database that displays all my records 1 at a time. The form has around 50 fields and a large photo for each record. I also have a Multiple Items Form that shows six fields and a small thumbnail photo for each record that I use for quick compares. What I would like to do is use my main form to filter for groups of records (in any of the 50 fields), then open and view them on the Multiple Items Form. That way I can quickly compare records as they are all on the same page. So my question is, is this possible and if so does it require code or can it be done with queries? I have done many searches on this but can’t come up with anything. Any suggestions?
Found the answer. All I needed to do was add a button to my Main Form with the code below. It takes whatever I have filter for and sorted on my Main Form and opens up my Multiple List Form with the same filters and sorts. - DoCmd.OpenForm "frmMyForm"
-
Forms!frmMyForm.Filter = Replace(Me.Filter, "[MyQurey].", "")
-
Forms!frmMyForm.FilterOn = True
-
Forms!frmMyForm.OrderBy = Replace(Me.OrderBy, "[MyQurey].", "")
-
Forms!frmMyForm.OrderByOn = True
3 2125
Here is how this can be accomplished: - Make an exact Copy (CTL+C ==> CTRL+V) of your Form and Name it frmFind.
- Make sure the Control Names of all Controls on frmFind are exactly the same as the Control Sources for these Controls.
- DELETE the Control Sources of all Controls on frmFind, I'm assuming these are Text Boxes.
- Add a Command Button with the Caption of Find on this Form.
- This will now be your Search Form. It is an exact Copy of your Main Form, but all the Fields are Blank, and the Form itself has no Record Source.
- Enter your Criteria in 1 or more Fields on frmFind.
- Add the following Code to the Click() Event of your Find Button.
-
Dim ctl As Control
-
Dim strBuild As String
-
-
For Each ctl In Me.Controls 'Loop thru all Controls on Form
-
If ctl.ControlType = acTextBox Then 'Only interested in Text Boxes
-
If Not IsNull(ctl) Then 'Text Box must have a Value in it
-
'Start building your Criteria String
-
If IsNumeric(ctl.Value) Then 'Number or String?
-
strBuild = strBuild & "[" & ctl.Name & "] = " & ctl.Value & " AND "
-
Else
-
strBuild = strBuild & "[" & ctl.Name & "] = '" & ctl.Value & "' AND "
-
End If
-
End If
-
End If
-
Next
-
-
'Strip " AND " from the end of strBuild (last 5 Characters)
-
strBuild = Left$(strBuild, Len(strBuild) - 5)
-
-
DoCmd.OpenForm "frmMultipleItems", acNormal, , , acFormReadOnly, acWindowNormal
-
-
'Change the Record Source of the Form based on the pre-defined Criteria
-
Forms!frmMultipleItems.RecordSource = "SELECT * FROM tblEmployees WHERE " & strBuild
-
- The Code will:
- Loop thru all the Controls on your Find Form.
- Filter for only Text Boxes that are NOT NULL.
- Build a Criteria String based on whether the Value(s) in the Text Boxes are Numeric or Strings.
- Strip Non-essential Characters from the Criteria String.
- Open frmMultipleItems.
- Dynamically set the Record Source of frmMultipleItems to reflect the Criteria that was just built.
- If you have any questions, please feel free to ask and one of us will help you. I have attempted to keep the solution as simple as possible. Perhaps someone else will come along with a more practical approach.
Hi ADezii
Thanks for the post. This is not exactly what I was looking for, but it does do exactly what I asked for it to do. So my fault for not explaining myself better. The problem is, due to the specific way I am doing the searches and the way my fields are set up. Here are the problems:
1. Half of my fields are list boxes or combo boxes, some of which do lookups on other tables.
2. Usually when I do a search in the database I start with one term and work down. So I would do a text filter on one field and then see how many results I get, if too many do another text filter on another field and so on. Sometimes they are filters for a words and other they are excluding words until I get down to what I want. So I don’t know what terms I am using until the search is done.
So I guess what I am looking to do is have it set up so that when I have done multiple filters and/or sort to get what I want on my main form, I click a button (on Main form) and my multiple list form come up with the exact same filters/sorts as my main form. I assume to accomplish that it would have to run off the same query that the main form is? I am just not sure how to link them up or if this is even possible? If you have any other idea’s let me know.
Thanks
P.S. I will use the code that you sent in another part of my database, it is really good. Thanks!
Found the answer. All I needed to do was add a button to my Main Form with the code below. It takes whatever I have filter for and sorted on my Main Form and opens up my Multiple List Form with the same filters and sorts. - DoCmd.OpenForm "frmMyForm"
-
Forms!frmMyForm.Filter = Replace(Me.Filter, "[MyQurey].", "")
-
Forms!frmMyForm.FilterOn = True
-
Forms!frmMyForm.OrderBy = Replace(Me.OrderBy, "[MyQurey].", "")
-
Forms!frmMyForm.OrderByOn = True
Sign in to post your reply or Sign up for a free account.
Similar topics
by: lokb |
last post by:
Hi,
I have a C function fread which does reading of multiple items as
num = fread(code,1,ilen-4,ifile);
which is reading 1 byte information ilen-4 times and updating to code
and returns a...
|
by: Steve |
last post by:
I have a listview that can get itself into a situation where multiple items have the LVIS_FOCUSED state. According to the documentation, LVIS_FOCUSED means
"The item has the focus, so it is...
|
by: ted |
last post by:
Hi,
I can't figure out how to set multiple items in a ListBox to selected when
the listbox is in a User Control.
When the ListBox is set in directly into a form I can use the following:...
|
by: Tom Bray |
last post by:
Ok I am baffled I can not figure out this problem. I am getting the
following error:
Portal Error - A DropDownList cannot have multiple items selected.
Error information
Name Value
Message...
|
by: sneha123 |
last post by:
There will be some 20 questions and for each question there will be 4
choices.what i want to do is to select multiple answers by clicking the
checkbox. i m using asp.net,vb.net
pls help me
we...
|
by: NumberCruncher |
last post by:
Hi All,
I am struggling with setting up my first system of tables, forms,and reports, and could use your help!
I am setting up a database to keep track of the production of a produced item. The...
|
by: anchi.chen |
last post by:
Hi People,
Just wondering if any of you have ever come across any javascript
examples that will allow one to drag and drop multiple items between
lists? That is, users would be able to use the...
|
by: reginaldmerritt |
last post by:
i wish to change the backcolor of a field on a current record being dispalyed in a 'multiple items' form. However when using me.fieldname01.backcolor = makes refrence to all fields called fieldname01...
|
by: swethak |
last post by:
hi
i wrote a code to select multiple items in a drop down list.And i store all the items in my database.But in that i select multiple items and submit that items last item only stored.Please...
|
by: loknath11 |
last post by:
I have problem with posting multiple items from sel2 to database without selection.It will so kind from you if you could look my code.
///certificate.php
<html>
<head>
<script...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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...
|
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,...
|
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...
| |