T
tsuby
Hi everybody,
I am working on my database and I am having difficulties with a search
form.
I have three forms:
SEARCH-FORM
MAINFORM and its SUBFORM
On the SEARCH-FORM I have textboxes and comboboxes for filtering the
mainform (with relevant subform) according to all criteria I entered.
If I search data belonging to the mainform, no problem, everything is
working, but if I try to open the mainform from criteria based on the
data belonging to the subform it is not working anymore.
The code behind the search button (for a combobox, in this case) is:
-----------
[...]
If Len(Me.Genere) > 0 Then
If Len(stLinkCriteria) > 0 Then
stLinkCriteria = stLinkCriteria & " AND [Genere] like
'" &
Me![Genere] & "*'"
Else
stLinkCriteria = "[Genere] like '" & Me![Genere] &
"*'"
End If
End If
'this is then repeated for all following criteria to combine
DoCmd.OpenForm stDocName, acNormal
With Forms("Frm_Audio_ALBUM")
.Filter = stLinkCriteria
.FilterOn = True
End With
----
With the mainform it works OK.
The relationship between the tables behind the forms is OK.
TABLE A (mainform) and TABLE B (subform) are linked with referential
integrity through a common data ("CatalogueNr").
The Primary key on both tables is an autonumber.
Mainform represents the data on Table A (let's say the customer), while
Subform represents the orders of the customer (TABLE B).
Being a newbie I guess that I should somehow change the code to "tell"
the mainform that it should open basing on the data from the subform.
The question is how.
Could you point me to the right direction, maybe with an example?
Thanks in advance
Erika
I am working on my database and I am having difficulties with a search
form.
I have three forms:
SEARCH-FORM
MAINFORM and its SUBFORM
On the SEARCH-FORM I have textboxes and comboboxes for filtering the
mainform (with relevant subform) according to all criteria I entered.
If I search data belonging to the mainform, no problem, everything is
working, but if I try to open the mainform from criteria based on the
data belonging to the subform it is not working anymore.
The code behind the search button (for a combobox, in this case) is:
-----------
[...]
If Len(Me.Genere) > 0 Then
If Len(stLinkCriteria) > 0 Then
stLinkCriteria = stLinkCriteria & " AND [Genere] like
'" &
Me![Genere] & "*'"
Else
stLinkCriteria = "[Genere] like '" & Me![Genere] &
"*'"
End If
End If
'this is then repeated for all following criteria to combine
DoCmd.OpenForm stDocName, acNormal
With Forms("Frm_Audio_ALBUM")
.Filter = stLinkCriteria
.FilterOn = True
End With
----
With the mainform it works OK.
The relationship between the tables behind the forms is OK.
TABLE A (mainform) and TABLE B (subform) are linked with referential
integrity through a common data ("CatalogueNr").
The Primary key on both tables is an autonumber.
Mainform represents the data on Table A (let's say the customer), while
Subform represents the orders of the customer (TABLE B).
Being a newbie I guess that I should somehow change the code to "tell"
the mainform that it should open basing on the data from the subform.
The question is how.
Could you point me to the right direction, maybe with an example?
Thanks in advance
Erika