Refresh a combo box on a sub-form

D

Dennis

Hi,

While in the main form, I want to requery / refresh a combo box on a
sub-form. Ive read a couple of forum discussion concerning this issue and
tried them, but it did not work. I'm doing somthing dumb.


My main form name is frmFamily
My sub-form name is frmFamily-sfMembers
The name of the combo box on the frmFamily-sfMembers is cboMemNo

While in the main form, I want to have Access requery cboMemNo on the
frmFamily-sfMembers.


While in the main form, I've tried:

Me!frmFamily-sfMembers.Form!cboMemNo.Requery

This results in the error message "Access can't find the field
'frmFamily-sfMembers' referred to in your expression.

I also tried:

Me.frmFamily-sfMembers.Form.cboMemNo.Requery

This resulst in the error message "method or data member not found".


I also tried:

Me![frmFamily-sfMembers].Form!cboMemNo.Requery

Which resulted in can't find the field "Access can't find the field
'frmFamily-sfMembers' referred to in your expression.


What am I doing wrong?


Thank you for your assitance.


Dennis
 
B

BruceM via AccessMonster.com

The last option should work, provided frmFamily-sfMembers is the name of the
subform control (the "box" containing the subform). Click the subform
control to select it, then click View >> Properties to see the name being
used.

The hyphen is a special character, so if it is used in a name you need square
brackets around the name. That is why the third option is the only one that
could work. It doesn't matter if you use the bang (!) or the dot.

Compiling the code (Debug >> Compile on the VBA editor menu) should have
detected naming problems. First, be sure you have Option Explicit directly
below Option Compare Database at the top of the code module.

Using Me. (dot rather than bang) should bring the intellisense feature into
play, whereby the list from which you can select is displayed as soon as you
type "Me.". The name of the subform control should be on that list. If it
is not, you need to check the name. Attempting to type in a control that
"should" be on the list but is not will likely result in an error.

Hi,

While in the main form, I want to requery / refresh a combo box on a
sub-form. Ive read a couple of forum discussion concerning this issue and
tried them, but it did not work. I'm doing somthing dumb.

My main form name is frmFamily
My sub-form name is frmFamily-sfMembers
The name of the combo box on the frmFamily-sfMembers is cboMemNo

While in the main form, I want to have Access requery cboMemNo on the
frmFamily-sfMembers.

While in the main form, I've tried:

Me!frmFamily-sfMembers.Form!cboMemNo.Requery

This results in the error message "Access can't find the field
'frmFamily-sfMembers' referred to in your expression.

I also tried:

Me.frmFamily-sfMembers.Form.cboMemNo.Requery

This resulst in the error message "method or data member not found".

I also tried:

Me![frmFamily-sfMembers].Form!cboMemNo.Requery

Which resulted in can't find the field "Access can't find the field
'frmFamily-sfMembers' referred to in your expression.

What am I doing wrong?

Thank you for your assitance.

Dennis
 
D

Dennis

Brue, Daryl,

Bruce,

Thank you for suggesting that I check the name of the subform control. That
was part of the problem.

I tried:

Me.frmFamily-sfMembers.cboMemNo.Requery

and the produced an error, so I tried:

Me.frmFamily-sfMembers.Form.cboMemNo.Requery

and that worked. Just for safely, I did put [] around the form name in my
final version and that worked also.

Thank you for your assitance. My form works great and I learned a little
more today!


Dennis
 

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