Solved "Enter PArameter Value" Error on subform (1 Viewer)

amir0914

Registered User.
Local time
Today, 02:54
Joined
May 21, 2018
Messages
151
Hi all,
I'm trying to filter subform by a combobox on main form, but the field on subform is unbounded control.(Dlookup from another table)

Code:
Private Sub txtBranch_AfterUpdate()
    With Me
    .Child01.Form.Filter = "[Text28] LIKE '" & Nz(.txtBranch, "*") & "'"
    .Child01.Form.FilterOn = True
    End With
End Sub

but it gives this error :
Screenshot (1842).png

WhenI I use the same code to a bounded control on subform, it works right.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 17:54
Joined
May 7, 2009
Messages
19,169
replace [Text28] with the FieldName in your subform.
 

amir0914

Registered User.
Local time
Today, 02:54
Joined
May 21, 2018
Messages
151
The unbounded field name on the subform is Text28 .
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 17:54
Joined
May 7, 2009
Messages
19,169
you can't filter an Unbound form.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 17:54
Joined
May 7, 2009
Messages
19,169
is [text28] calculated? coming from a Query ?
if not then you need to filter on bound field.
 

amir0914

Registered User.
Local time
Today, 02:54
Joined
May 21, 2018
Messages
151
is [text28] calculated? coming from a Query ?
if not then you need to filter on bound field.
No, it's a dlookup field based on another bound field :
Text28 Control source : =DLookUp("UnitName","tbl_Units"," UnitCode = '" & [UnitCode] & "'")

[UnitCode] is a bound field on the subform and I'm using dlookup in Text28 to call unit name on subform. now my problem is that filter on subform based on [UnitCode] is working right but it gives error to [Text28].
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 17:54
Joined
May 7, 2009
Messages
19,169
i suggest using Query and incorporating the Unbound Column in your query:

select yourTable.*, tbl_UNits.UnitName From yourTable Left Join tblUnits On yourTable.UnitCode = tbl_Units.UnitCode;

substitute your Tablename to "yourTable" and use this query as Recordsource of your subform.
now your your Filter will look like this:

Code:
Private Sub txtBranch_AfterUpdate()
    With Me
    .Child01.Form.Filter = "[UnitName] LIKE '" & Nz(.txtBranch, "*") & "'"
    .Child01.Form.FilterOn = True
    End With
End Sub
 

Minty

AWF VIP
Local time
Today, 09:54
Joined
Jul 26, 2013
Messages
10,353
Join the Unit code in your forms underlying query record source?
 

amir0914

Registered User.
Local time
Today, 02:54
Joined
May 21, 2018
Messages
151
i suggest using Query and incorporating the Unbound Column in your query:

select yourTable.*, tbl_UNits.UnitName From yourTable Left Join tblUnits On yourTable.UnitCode = tbl_Units.UnitCode;

substitute your Tablename to "yourTable" and use this query as Recordsource of your subform.
now your your Filter will look like this:

Code:
Private Sub txtBranch_AfterUpdate()
    With Me
    .Child01.Form.Filter = "[UnitName] LIKE '" & Nz(.txtBranch, "*") & "'"
    .Child01.Form.FilterOn = True
    End With
End Sub
Thank you so much.
 

Users who are viewing this thread

Top Bottom