filter main form from a popup form

L

ljr

On my main form, I hav a button that will open a popup form. The popup form
has unbound combo boxes to allow user to select criteria. Once criteria is
selected, the form footer is visible, which is a subform listing records
based on critera. I also have a field on the subform "edit" which when
selected, I want to filter the main form to the record selected. On
"edit_click" I have the following code but no matter what I do, I'm not
getting it to work.
I keep getting "Run-time error '2465':
Application-defined or object-defined error"

Form.frmMain.Form.Filter = "'" & [KronosNo] = " & Me.KronosNo & '"
DoCmd.Close , "frmSelectedVehSearch"
 
S

Stuart McCall

ljr said:
On my main form, I hav a button that will open a popup form. The popup
form
has unbound combo boxes to allow user to select criteria. Once criteria
is
selected, the form footer is visible, which is a subform listing records
based on critera. I also have a field on the subform "edit" which when
selected, I want to filter the main form to the record selected. On
"edit_click" I have the following code but no matter what I do, I'm not
getting it to work.
I keep getting "Run-time error '2465':
Application-defined or object-defined error"

Form.frmMain.Form.Filter = "'" & [KronosNo] = " & Me.KronosNo & '"
DoCmd.Close , "frmSelectedVehSearch"

You need to refer to the form via the Forms collection:

Forms!frmMain.Form.Filter = "'" & [KronosNo] = " & Me.KronosNo & '"

Also you can take out the .Form part. It's not needed, but is doing no harm.
Your call.
 
D

Douglas J. Steele

Stuart McCall said:
ljr said:
On my main form, I hav a button that will open a popup form. The popup
form
has unbound combo boxes to allow user to select criteria. Once criteria
is
selected, the form footer is visible, which is a subform listing records
based on critera. I also have a field on the subform "edit" which when
selected, I want to filter the main form to the record selected. On
"edit_click" I have the following code but no matter what I do, I'm not
getting it to work.
I keep getting "Run-time error '2465':
Application-defined or object-defined error"

Form.frmMain.Form.Filter = "'" & [KronosNo] = " & Me.KronosNo & '"
DoCmd.Close , "frmSelectedVehSearch"

You need to refer to the form via the Forms collection:

Forms!frmMain.Form.Filter = "'" & [KronosNo] = " & Me.KronosNo & '"


I'm not sure that the quotes are correct.

Forms!frmMain.Form.Filter = " ' " & [KronosNo] = " & Me.KronosNo & ' "

I think they should be:

Forms!frmMain.Form.Filter = "[KronosNo] = " & Me.KronosNo
 
L

ljr

It worked. I had the orginal line as
form.frmMain.form.filter.......
should have been forms.frmMain......
I was missing the "s"

Thank you both and yes Doug you were correct in quotes. All is working
great now.


Douglas J. Steele said:
Stuart McCall said:
ljr said:
On my main form, I hav a button that will open a popup form. The popup
form
has unbound combo boxes to allow user to select criteria. Once criteria
is
selected, the form footer is visible, which is a subform listing records
based on critera. I also have a field on the subform "edit" which when
selected, I want to filter the main form to the record selected. On
"edit_click" I have the following code but no matter what I do, I'm not
getting it to work.
I keep getting "Run-time error '2465':
Application-defined or object-defined error"

Form.frmMain.Form.Filter = "'" & [KronosNo] = " & Me.KronosNo & '"
DoCmd.Close , "frmSelectedVehSearch"

You need to refer to the form via the Forms collection:

Forms!frmMain.Form.Filter = "'" & [KronosNo] = " & Me.KronosNo & '"


I'm not sure that the quotes are correct.

Forms!frmMain.Form.Filter = " ' " & [KronosNo] = " & Me.KronosNo & ' "

I think they should be:

Forms!frmMain.Form.Filter = "[KronosNo] = " & Me.KronosNo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top