SubForm Combo Box Default Value

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a master form called DesignMaster, and a subform named DT, in DT I
have a projectname combo box that I would like to get a default value from
the combo box on the DesignMaster that is unbound and is only selecting the
record to be displayed on the main form.

Here is what I had in OnCurrent of DesignMaster and Afterupdate on the main
form combo, Combo0.
Me.DT.Projectnamedes.DefaultValue = Me.Combo0
It is not working, any help would be great.
 
What's not working? Are you getting an error? If so, what is it? Are you
expecting to see the value of ProjectNamedes change and it isn't? Well, it
won't. You have set the Default Value, not the Value. So, the value you
entered won't be seen until the next time you move the subform to a new,
blank record.
 
ANy thoughts on how I make the value come up? I am using a refresh button
also.
Any help would be greatly appreciated, I have been struggling with this for
a week!!
Thanks,
 
Nothing happens, zero. No error message or anything.
The field ProjectNamedes is blank to start with, so I was expecting it to be
populated with the name in the combo box after update, like every other field
on the main form. I also have a refresh button on the form and I get nothing
when that is pressed also. The only thing that does happen is that the top
name on the list in the combo box projectnamedes appears in the field.
Does this help?
 
I believe the problem comes in the way you are expecting Default Value to
work. Setting the Default Value of a control will cause that control to have
that value displayed when you move to a new record. If you're already on a
new record and change the Default Value property of the control, you won't
see the effect of doing that until you move to the next new record (i.e. the
Default Value has to be set BEFORE you move to a new record for the Default
Value to have an effect).

If you are wanting to see an immediate change in the value depicted in a
control, you need to change the control's Value, not its Default Value.
 
Change

Me.DT.Projectnamedes.DefaultValue = Me.Combo0
to
Me.DT.Projectnamedes.Value = Me.Combo0
or, since Value is the default property, it can be dropped
Me.DT.Projectnamedes = Me.Combo0
 
I get a compile error that says Method or Data Member Not Found
It highlights the .Projectnamedes =
 
Well, if that wasn't found, you should have had the same error with the
DefaultValue. However, let's see if we can work through it. "Me" is the form
on which the code is running. Is that the main form or the subform? If it is
the main form, then DT should be the name of the subform control on the main
form, not the name of the subform; but they may both be the same. To then
refer to a control on the subform, there are two options. Use a ! instead of
a . or refer to the Form object first.

Example:
Me.DT!Projectnamedes = Me.Combo0
or
Me.DT.Form.Projectnamedes = Me.Combo0
 
Back
Top