473,387 Members | 1,592 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,387 software developers and data experts.

Running a Multiple Items Form off a Standard Form

112 100+
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?
Jun 6 '13 #1

✓ answered by Redbeard

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.
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenForm "frmMyForm"
  2. Forms!frmMyForm.Filter = Replace(Me.Filter, "[MyQurey].", "")
  3. Forms!frmMyForm.FilterOn = True
  4. Forms!frmMyForm.OrderBy = Replace(Me.OrderBy, "[MyQurey].", "")
  5. Forms!frmMyForm.OrderByOn = True

3 2125
ADezii
8,834 Expert 8TB
Here is how this can be accomplished:
  1. Make an exact Copy (CTL+C ==> CTRL+V) of your Form and Name it frmFind.
  2. Make sure the Control Names of all Controls on frmFind are exactly the same as the Control Sources for these Controls.
  3. DELETE the Control Sources of all Controls on frmFind, I'm assuming these are Text Boxes.
  4. Add a Command Button with the Caption of Find on this Form.
  5. 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.
  6. Enter your Criteria in 1 or more Fields on frmFind.
  7. Add the following Code to the Click() Event of your Find Button.
    Expand|Select|Wrap|Line Numbers
    1. Dim ctl As Control
    2. Dim strBuild As String
    3.  
    4. For Each ctl In Me.Controls             'Loop thru all Controls on Form
    5.   If ctl.ControlType = acTextBox Then   'Only interested in Text Boxes
    6.     If Not IsNull(ctl) Then             'Text Box must have a Value in it
    7.       'Start building your Criteria String
    8.       If IsNumeric(ctl.Value) Then      'Number or String?
    9.         strBuild = strBuild & "[" & ctl.Name & "] = " & ctl.Value & " AND "
    10.       Else
    11.         strBuild = strBuild & "[" & ctl.Name & "] = '" & ctl.Value & "' AND "
    12.       End If
    13.     End If
    14.   End If
    15. Next
    16.  
    17. 'Strip " AND " from the end of strBuild (last 5 Characters)
    18. strBuild = Left$(strBuild, Len(strBuild) - 5)
    19.  
    20. DoCmd.OpenForm "frmMultipleItems", acNormal, , , acFormReadOnly, acWindowNormal
    21.  
    22. 'Change the Record Source of the Form based on the pre-defined Criteria
    23. Forms!frmMultipleItems.RecordSource = "SELECT * FROM tblEmployees WHERE " & strBuild
    24.  
  8. The Code will:
    1. Loop thru all the Controls on your Find Form.
    2. Filter for only Text Boxes that are NOT NULL.
    3. Build a Criteria String based on whether the Value(s) in the Text Boxes are Numeric or Strings.
    4. Strip Non-essential Characters from the Criteria String.
    5. Open frmMultipleItems.
    6. Dynamically set the Record Source of frmMultipleItems to reflect the Criteria that was just built.
  9. 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.
Jun 6 '13 #2
Redbeard
112 100+
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!
Jun 10 '13 #3
Redbeard
112 100+
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.
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenForm "frmMyForm"
  2. Forms!frmMyForm.Filter = Replace(Me.Filter, "[MyQurey].", "")
  3. Forms!frmMyForm.FilterOn = True
  4. Forms!frmMyForm.OrderBy = Replace(Me.OrderBy, "[MyQurey].", "")
  5. Forms!frmMyForm.OrderByOn = True
Jun 12 '13 #4

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

Similar topics

5
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...
1
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...
3
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:...
2
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...
1
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...
1
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...
2
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...
10
reginaldmerritt
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...
4
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...
1
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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$) { } ...
0
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...

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.