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

amir0914

Registered User.
Local time
Today, 02:06
Joined
May 21, 2018
Messages
102
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

error reading drive A:
Local time
Today, 18:06
Joined
May 7, 2009
Messages
11,116
replace [Text28] with the FieldName in your subform.
 

amir0914

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

arnelgp

error reading drive A:
Local time
Today, 18:06
Joined
May 7, 2009
Messages
11,116
is [text28] calculated? coming from a Query ?
if not then you need to filter on bound field.
 

amir0914

Registered User.
Local time
Today, 02:06
Joined
May 21, 2018
Messages
102
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

error reading drive A:
Local time
Today, 18:06
Joined
May 7, 2009
Messages
11,116
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, 10:06
Joined
Jul 26, 2013
Messages
7,735
Join the Unit code in your forms underlying query record source?
 

amir0914

Registered User.
Local time
Today, 02:06
Joined
May 21, 2018
Messages
102
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