Hello,
I have set up a form which will be used for filtering reports. I would like to be able to generate a single report and in order to do that I will have to filter three fields.
I am using three combo boxes to achieve this. The three fields I am filtering are as follows: Tenant Name, Building Name, and Unit
The Tenant Name and Building Name work perfectly but I can't get the rowsource for Unit to display any values.
Here is what I have so far:
For the tenant name:
rowsource:
The above displays all the tenants that currently have leases.
Once the Tenant Name is selected the Building combobox is populated with all the buildings leased to the selected tenant (Tenants can lease more than one building). This is achieved by the following:
rowsource:
This also works perfectly. Only the buildings that are occupied by the tenant are displayed.
Now for my problem. Because, not only can the tenant be holding a lease in more than one building, but they can also have more then one lease in the specific building (ie for a specific Unit number). So what I am trying to do is to have the Unit combobox display only the unit numbers that the selected tenant is leasing in the selected building.
I tried to simply modify the rowsource of building name but it is not working (the combo box is always null).
rowsource:
So this is where I need help. This is very important to my project because, it is the only way I see being able to filter my report to a single specific lease.
Also, not sure if it will be useful, but I had trouble to get just the first two comboboxes working but I eventually succeeded, so if anyone is interested on how to achieve these to update here is the code:
It is only basically three functions:
'this is the "On Current" even of the form
'this is "On Change" event in the the tenant combo box. the building part 'works but the unit combo doesn't. However, I'm pretty sure it is a problem 'with the actual query not the code below
'this is "On Change" event in the building Combobox, however it is not doing 'anything for me now.
Thanks in advance for any input you might have.
Eric
I have set up a form which will be used for filtering reports. I would like to be able to generate a single report and in order to do that I will have to filter three fields.
I am using three combo boxes to achieve this. The three fields I am filtering are as follows: Tenant Name, Building Name, and Unit
The Tenant Name and Building Name work perfectly but I can't get the rowsource for Unit to display any values.
Here is what I have so far:
For the tenant name:
rowsource:
Code:
SELECT Tenants.[Tenant Name] FROM Tenants ORDER BY [Tenant Name];
The above displays all the tenants that currently have leases.
Once the Tenant Name is selected the Building combobox is populated with all the buildings leased to the selected tenant (Tenants can lease more than one building). This is achieved by the following:
rowsource:
Code:
SELECT distinct Leases.LeaseID, Leases.[buildingName] FROM Leases WHERE (((Leases.Tenant)=[forms]![Lease Offer]![tenantCombo])) UNION select distinct null, null FROM Leases ORDER BY Leases.[buildingName];
This also works perfectly. Only the buildings that are occupied by the tenant are displayed.
Now for my problem. Because, not only can the tenant be holding a lease in more than one building, but they can also have more then one lease in the specific building (ie for a specific Unit number). So what I am trying to do is to have the Unit combobox display only the unit numbers that the selected tenant is leasing in the selected building.
I tried to simply modify the rowsource of building name but it is not working (the combo box is always null).
rowsource:
Code:
SELECT distinct Leases.LeaseID, Leases.[Unit] FROM Leases WHERE (((Leases.Tenant)=[forms]![Lease Offer]![tenantCombo]) AND ((Leases.buildingName)=[forms]![Lease Offer]![buildingCombo])) UNION select distinct null, null FROM Leases ORDER BY Leases.[Unit];
So this is where I need help. This is very important to my project because, it is the only way I see being able to filter my report to a single specific lease.
Also, not sure if it will be useful, but I had trouble to get just the first two comboboxes working but I eventually succeeded, so if anyone is interested on how to achieve these to update here is the code:
It is only basically three functions:
'this is the "On Current" even of the form
Code:
Private Sub Form_Current()
buildingCombo.Requery
unitCombo.Requery
End Sub
'this is "On Change" event in the the tenant combo box. the building part 'works but the unit combo doesn't. However, I'm pretty sure it is a problem 'with the actual query not the code below
Code:
Private Sub tenantCombo_Change()
buildingCombo.Value = Null
unitCombo.Value = Null
buildingCombo.Requery
unitCombo.Requery
End Sub
'this is "On Change" event in the building Combobox, however it is not doing 'anything for me now.
Code:
Private Sub buildingCombo_Change()
unitCombo.Value = Null
unitCombo.Requery
End Sub
Thanks in advance for any input you might have.
Eric