473,405 Members | 2,349 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,405 software developers and data experts.

Mainform and multiple subforms search...

hi all

i need someone to help me with a code that will enable me filter records in a subform form through a combo box attached to a mainform-that has a main menu that controls all the sub form that runs under sourceObject on the mainform unbound frame.

like, when i a company name on mainform combo box then the subform shows only records for that company. eg like how it works when filtering a query..

regards. lovelydan

P.S. subforms runs through a code; Me.Subform.SourceObject=""

e.g. Me.Subform.SourceObject="Ässets"
Apr 28 '09
64 6716
look at the code and c where i went wrong..
May 1 '09 #51
NeoPa

i tried all the tricks over the weekend.. did u manage to look at code...!
May 4 '09 #52
NeoPa

welcome back from the holiday...hope you enjoyed the rest..

have you look at the problem yet..?
May 5 '09 #53
NeoPa
32,556 Expert Mod 16PB
I'm sorry Dan.

I had a quick look but didn't get the time to look in enough detail to be of any help. I still have it to do, but can't say when I will be able to. I'll try tonight, but I'm out every evening till Thursday, so may have to wait until Friday.

We'll see what we can manage.
May 5 '09 #54
NeoPA

okay thanks...
May 5 '09 #55
NeoPA;

just a reminder...i know you always have your dish full..
May 7 '09 #56
NeoPa
32,556 Expert Mod 16PB
That's fine Dan.

I was out both of the last two evenings and didn't even get to turn on my PC.

I still have this thread as a saved page until I can get a chance to look it over. Bumping is not a problem though if ever you're curious to know where I'm at on it.
May 7 '09 #57
NeoPa
32,556 Expert Mod 16PB
You have the code handling this as :
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmbMinistryName_AfterUpdate()
  2. Dim strFilter As String
  3.     With Me.SubForm.Form
  4.     ' This assumes Handle is a text field
  5.     strFilter = "[MinName] Like '" & Me.cmbMinistryName & "*'"
  6.     .Filter = strFilter
  7.     .FilterOn = True
  8.     Call .Requery
  9.     End With
  10. End Sub
You could have posted this instead of the whole database as an attachment and we could have got this quicker and easier.

The problem is your use of Me.cmbMinistryName in line #5. You probably think the value will be a name ("MOE" or "MOH"), but it's actually just the [minID] field, which is numeric.

Look at the design of cmbMinistryName.
Column Count = 2 (minID & minName)
Column Widths = 0;2.54cm
Bound Column = 1

That last is the important one. That means the value of the ComboBox (when referred to as in Me.cmbMinistryName) is the minID column. So, you get 1 instead of "MOH" & 15 instead of "MOE".

Try instead :
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmbMinistryName_AfterUpdate()
  2. Dim strFilter As String
  3.     With Me.SubForm.Form
  4.         ' This assumes Handle is a text field
  5.         strFilter = "[MinName] Like '" & Me.cmbMinistryName.Column(1) & "*'"
  6.         .Filter = strFilter
  7.         .FilterOn = True
  8.         'Following line not actually required after setting .Filter
  9.         'Call .Requery
  10.     End With
  11. End Sub
Otherwise the code looks perfect.

Having seen the database of course, I can say I was impressed by the design and workings of it.
May 7 '09 #58
eeeh. programming is not a joke neh...i have never done VB at school i just got interested and started reading books and the outcome was fruitful.

thanks bout the design...i was confident but now u make me feel more confident and willing to do more.

thanks, its working now...im glad. now i have to work on the other combo boxes...

regards,Lovely
May 8 '09 #59
NeoPa
32,556 Expert Mod 16PB
I think you'll probably find they all suffer from the same misunderstanding. They should all be easy to fix now.

Good luck :)
May 8 '09 #60
okay, now i want to filter using the 1st and second combo box and i added the following code line number 5;
Expand|Select|Wrap|Line Numbers
  1. strFilter = "[MinName] Like '" & Me.cmbMinistryName.Column(1) & "*'" And _
  2. "[MinDistrict] Like '" & Me.cmbDistrict.Column(1) & "*'"
and im getting an error message "Type mismatch"

any help..!
May 8 '09 #61
NeoPa
32,556 Expert Mod 16PB
Your And is outside of your string. You seem to be confusing AND with &.

PS. Please don't make me have to give you a proper infraction for not using the CODE tags again Dan. That would be unfortunate, but unavoidable if you forget again.
May 8 '09 #62
sorry again 4 tagging.. are you sayin i should use "&" instead of "AND". i tried it and i still get the error. NeoPa, im still an a learner on this, but i wii get there. so where im i suppose to amend.
May 8 '09 #63
NeoPa
thanks..i got it and i really appriciate your help.

my regards, Lovely
May 8 '09 #64
NeoPa
32,556 Expert Mod 16PB
That's good Dan.

Basically, & is used to concatenate (join together) strings in VBA, whereas "AND" is used within the SQL itself, to join two distinct WHERE phrases together.
May 8 '09 #65

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

Similar topics

1
by: William Bradley | last post by:
At the moment I am having a problem with relationships and updating tables. The following is a production run. Table1 -- MainFormTable1 -- Basic Table Record Table2 ----SubFormTable2 --...
0
by: Dalan | last post by:
I'm sure there is a workaround for this, but haven't found it yet. I have a mainform with two subforms and after one or both of the subforms are updated, then clicking the Refresh button on the...
0
by: misscrf | last post by:
I am currently working on a database, in 3rd normal form, which is for candidates who apply for a job with the law firm that I workd for. My issue is with good form design. I have a main...
11
by: dskillingstad | last post by:
I've been struggling with this problem for some time and have tried multiple solutions with no luck. Let me start with, I'm a novice at Access and I'm not looking for someones help to design my...
0
by: cwm137 | last post by:
I have a form named "Customer Search" with a subform called "Cust Search Subform" that contains summary data about every order a customer has made. I would like to be able to select a single order...
12
by: Wadim Grasza | last post by:
I want to store and display (on a form or a report) multiple pictures per record in an access database. The pictures are not stored within the database. They are stored as files and the database...
5
by: jedraw | last post by:
I am trying to use the information provided in Allen Brownes response see Response. I have a mainform, a tabctl with 5 pages , 5 subforms and 1 subfrom control. I placed the subformname in the...
18
by: Robert Jacobs | last post by:
Please advise... I currently have a Mainform (Customers) and a Subform (Service Requests) with a one to many relationship (one customer, many service requests) with a CustomerID that is unique...
14
by: JonOle | last post by:
In Access 2007 I have a main form with several subforms. All forms are unbound, and the recordsets for the forms are set during the OnOpen-event in the main-form. I use ADO and OleDB to connect to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
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
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...

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.