Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

2455 error

Status
Not open for further replies.

sub5

Programmer
Oct 12, 2005
104
Hi all,
I have form1 which opens form2. On form2 are two subforms.
subform1 has an on current event:
dim strCond as string
strCond = "ID = forms!form2!sub1.form!ID"
forms!form2!sub2.form.filteron = true
forms!form2!sub2.form.filter = strCond
When I have the recordsource of sub1 including a criteria reference to a field ie forms!form2!ID, then everything works OK. But if I change the critera to a number say 257, which is an ID that exists, I get the following error when I try to open form2:
2455 you entered an expression that has an invalid reference to the property form/report
debug takes me to the ....filteron = true line of code

Any ideas?
 
I doubt that this works.

strCond = "ID = forms!form2!sub1.form!ID"

it should be
strCond = "ID = " & forms!form2!sub1.form!ID
or if the field is text
strCond = "ID = '" & forms!form2!sub1.form!ID & "'"

Is your syntax

strCond = "ID = " & 256
 
This query also appears in:
filter by form refering to a column in a control or a variable
thread705-1233517
 
Hi majp
Thanks for your response.
I Changed the first syntax as you suggested.
My id = 256 is not in syntax, it is in the recordsource query criteria of sub form1 simply as 256 under field ID
 
MajP
I have tried
[tt]strCond = "ID = forms!form2!sub1.form!ID"[/tt]
and it seems to work ok. You end up with a filter
[tt]ID = forms!form2!sub1.form!ID[/tt]
Which is a valid filter.
 
sub5
I think this error is due to the event you have used. Does the error occur when you first open the form. have you tried taking the code out of the On Current event for the sub form and put it in some other event, say the On Current event for the main form?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top