Filter 2nd form based on field value of 1st form

Y

Yara

Hi there,
I have a mainform with 3 subforms included. On the first subform there is a
combobox field [CboEquipmment]. When I press a button I would like to have
another form opened that is filtered so that it shows only the relevant
records. The first form name is SubfrmEquipment and is based on a table
TblEquipment. The 2nd form is named FrmFunction and is also based on the
TblEquipment. The 2nd form is a continous form.

I hope that I have explained the situation so that someone can help me with
this.

Any help is much appreciated!

Yara
 
T

Tom van Stiphout

On Sun, 10 Jan 2010 11:13:01 -0800, Yara

DoCmd.OpenForm "FrmFunction", , , "EquipmentID=" & Me.CboEquipment
I'm assuming your combobox has two columns, EquipmentID and
EquipmentName.

-Tom.
Microsoft Access MVP
 
Y

Yara

Hi Tom,

Thanks for your code.

I have tried to use the code you have posted but it doesn't work. I get the
debug prompt. Can you give more info?

I am using subfrmEquipment with CboEquipment (your assumprion was correct it
has 2 columns). By pressing a cmdbutton a form named FrmFunction should be
opened and filtered based on the value in CboEquipment. The form FrmFunction
is a continious form. Both forms have the TblEquipment as source.
What am I doing wrong?

Regards,
Mireille



Tom van Stiphout said:
On Sun, 10 Jan 2010 11:13:01 -0800, Yara

DoCmd.OpenForm "FrmFunction", , , "EquipmentID=" & Me.CboEquipment
I'm assuming your combobox has two columns, EquipmentID and
EquipmentName.

-Tom.
Microsoft Access MVP

Hi there,
I have a mainform with 3 subforms included. On the first subform there is a
combobox field [CboEquipmment]. When I press a button I would like to have
another form opened that is filtered so that it shows only the relevant
records. The first form name is SubfrmEquipment and is based on a table
TblEquipment. The 2nd form is named FrmFunction and is also based on the
TblEquipment. The 2nd form is a continous form.

I hope that I have explained the situation so that someone can help me with
this.

Any help is much appreciated!

Yara
.
 
T

Tom van Stiphout

On Tue, 12 Jan 2010 11:08:01 -0800, Yara

Set a breakpoint at this line. When you stop at this line, in the
immediate window, write:
?Me.CboEquipment
I expect it will return with a numeric value, e.g. 5.
That means that essentially we are executing:
DoCmd.OpenForm "FrmFunction", , , "EquipmentID=" & 5
and that should work, if indeed this form is bound to a table (or
query) with EquipmentID in it.
If EquipmentID is a text value, you should wrap single-quotes around
it:
DoCmd.OpenForm "FrmFunction", , , "EquipmentID='" & Me.CboEquipment &
"'"

-Tom.
Microsoft Access MVP

Hi Tom,

Thanks for your code.

I have tried to use the code you have posted but it doesn't work. I get the
debug prompt. Can you give more info?

I am using subfrmEquipment with CboEquipment (your assumprion was correct it
has 2 columns). By pressing a cmdbutton a form named FrmFunction should be
opened and filtered based on the value in CboEquipment. The form FrmFunction
is a continious form. Both forms have the TblEquipment as source.
What am I doing wrong?

Regards,
Mireille



Tom van Stiphout said:
On Sun, 10 Jan 2010 11:13:01 -0800, Yara

DoCmd.OpenForm "FrmFunction", , , "EquipmentID=" & Me.CboEquipment
I'm assuming your combobox has two columns, EquipmentID and
EquipmentName.

-Tom.
Microsoft Access MVP

Hi there,
I have a mainform with 3 subforms included. On the first subform there is a
combobox field [CboEquipmment]. When I press a button I would like to have
another form opened that is filtered so that it shows only the relevant
records. The first form name is SubfrmEquipment and is based on a table
TblEquipment. The 2nd form is named FrmFunction and is also based on the
TblEquipment. The 2nd form is a continous form.

I hope that I have explained the situation so that someone can help me with
this.

Any help is much appreciated!

Yara
.
 
Y

Yara

Hi Tom,

Thanks again for your support. I have done exactly what you said and it gave
back a number just as you said. I have tried al sorts of combinations but
nothing seemed to help. Eventually I have started all over again and now it
works fine.
So something was wrong with a table or form or so.
Thanks again!

Regards,
Yara

Tom van Stiphout said:
On Tue, 12 Jan 2010 11:08:01 -0800, Yara

Set a breakpoint at this line. When you stop at this line, in the
immediate window, write:
?Me.CboEquipment
I expect it will return with a numeric value, e.g. 5.
That means that essentially we are executing:
DoCmd.OpenForm "FrmFunction", , , "EquipmentID=" & 5
and that should work, if indeed this form is bound to a table (or
query) with EquipmentID in it.
If EquipmentID is a text value, you should wrap single-quotes around
it:
DoCmd.OpenForm "FrmFunction", , , "EquipmentID='" & Me.CboEquipment &
"'"

-Tom.
Microsoft Access MVP

Hi Tom,

Thanks for your code.

I have tried to use the code you have posted but it doesn't work. I get the
debug prompt. Can you give more info?

I am using subfrmEquipment with CboEquipment (your assumprion was correct it
has 2 columns). By pressing a cmdbutton a form named FrmFunction should be
opened and filtered based on the value in CboEquipment. The form FrmFunction
is a continious form. Both forms have the TblEquipment as source.
What am I doing wrong?

Regards,
Mireille



Tom van Stiphout said:
On Sun, 10 Jan 2010 11:13:01 -0800, Yara

DoCmd.OpenForm "FrmFunction", , , "EquipmentID=" & Me.CboEquipment
I'm assuming your combobox has two columns, EquipmentID and
EquipmentName.

-Tom.
Microsoft Access MVP


Hi there,
I have a mainform with 3 subforms included. On the first subform there is a
combobox field [CboEquipmment]. When I press a button I would like to have
another form opened that is filtered so that it shows only the relevant
records. The first form name is SubfrmEquipment and is based on a table
TblEquipment. The 2nd form is named FrmFunction and is also based on the
TblEquipment. The 2nd form is a continous form.

I hope that I have explained the situation so that someone can help me with
this.

Any help is much appreciated!

Yara
.
.
 

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

Top