Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / New Users / July 2006

Tip: Looking for answers? Try searching our database.

Trouble getting Default Value to work for combo box.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
David Newmarch - 06 Jul 2006 12:46 GMT
On an order details subform sfrOrderDetails I have a combo box
cboSetRebateID. The combo box works fine, but I want it to have (and display)
a default value (which can then be overridden if necessary) that is picked up
from a different control, txtDefaultRebateID on the same form.  (The
txtDefaultRebateID value is set elsewhere and can differ from row to row; it
displays correctly.)

The Default Value property for the cboSetRebateID combo is entered as
=[Form]![sfrOrderDetails]![txtDefaultRebateID].

I’ve tried this with and without the equals sign, and I’ve made sure that
the control txtDefaultRebateID comes before cboSetRebateID in the tab order
sequence. But unless you make a selection the combo still just displays the
first value in its drop-down list, apparently ignoring the default property.

What could I be doing wrong?
Rick Brandt - 06 Jul 2006 13:44 GMT
> On an order details subform sfrOrderDetails I have a combo box
> cboSetRebateID. The combo box works fine, but I want it to have (and
[quoted text clipped - 13 lines]
>
> What could I be doing wrong?

You cannot use the value entered in one control as the default value of
another control because the default value is assigned as soon as the new
record is painted on the screen and the first control won't have a value in
it yet.

What you can do is copy the value entered in one control into a second
control in the first control's AfterUpdate event.  The user would still be
free to change the second control afterwards to some other value, but if
they don't it will retain the same vvalue as the first control.

Signature

Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt   at   Hunter   dot   com

David Newmarch - 06 Jul 2006 14:50 GMT
Thanks, Rick, for the explanation.

But I've now inserted this code where you suggest

Private Sub txtDefaultRebateID_AfterUpdate()
   Me.cboSetRebateID = Me.txtDefaultRebateID
End Sub

and it still doesn't work. (Also deleted the Default Value property from the
combo box.) Could it be a problem that the text box (txtDefaultRebateID) is
automatically pulls a value from its underlying query when you go to a new
record on the subform? Does that count as an AfterUpdate situation?

> > On an order details subform sfrOrderDetails I have a combo box
> > cboSetRebateID. The combo box works fine, but I want it to have (and
[quoted text clipped - 23 lines]
> free to change the second control afterwards to some other value, but if
> they don't it will retain the same vvalue as the first control.
David Newmarch - 06 Jul 2006 15:13 GMT
OK, I've now tried putting the code you suggested into the OnCurrent event
forthe form itself and that seems to have done the trick.

Thanks very much Rick for your help. I still feeling my way around event
properties and learning which ones to use.

> > On an order details subform sfrOrderDetails I have a combo box
> > cboSetRebateID. The combo box works fine, but I want it to have (and
[quoted text clipped - 23 lines]
> free to change the second control afterwards to some other value, but if
> they don't it will retain the same vvalue as the first control.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.