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 / General 1 / December 2005

Tip: Looking for answers? Try searching our database.

default value help

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ken - 16 Dec 2005 02:03 GMT
Hi,
I want to reset the default value of a combo box everytime someone
selects something from its list.
I have in the after update event combo.defaultvalue = combo.value.
Anyhow this works, as long as I don't close the form. Once I close it
the new defalut value does not get saved. Is there any way I could save
it to the properties of the combo box?

Thanks,
Using A2k.
fredg - 16 Dec 2005 06:14 GMT
> Hi,
> I want to reset the default value of a combo box everytime someone
[quoted text clipped - 6 lines]
> Thanks,
> Using A2k.

You cannot save a change in a combo box property unless you change it
in Design View.

I would suggest you create a table with one field and one record.

Field Name    NewDefault      Set it's datatype to whatever the
datatype is of the combo box bound column.
Table Name   tblDefault

to store whatever the last selected value is (in the Combo AfterUpdate
event)

' First change the default value for use while this form is still
open.
Me!ComboName.DefaultValue = Me!ComboName

' Then save the value to the table.
CurrentDb.Execute "Update tblDefault Set tblDefault.NewDefault = " &
Me.ComboName & ";",dbFailOnError

The above assumes the bound column is a Number datatype.

Then DLookUp that value when you next open the form (in the Form's
Load event):

Me!ComboName.DefaultValue = DLookUp("[NewDefault]","tblDefault")

You do know, I hope,  that the DefaultValue will only come into play
for new records?
Signature

Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail

ken - 16 Dec 2005 17:18 GMT
>You do know, I hope,  that the DefaultValue will only come into play
>for new records?
Yes I know this...

I was hoping there would be another way other then making a tblDefault.
I wonder if I can use globals maybe? But I think they will be lost
after you close the form too.... I'll have to play with it.

Thanks for your help.
Rick Brandt - 16 Dec 2005 17:30 GMT
> > You do know, I hope,  that the DefaultValue will only come into play
> > for new records?
[quoted text clipped - 6 lines]
>
> Thanks for your help.

If you need the default value to persist between form sessions you could put it
into a global variable.  Some prefer to use controls on a hidden form for this
(global variables not being very stylish these days).

If you need the default value to persist between application sessions then you
should store it in a table and retrieve it when the form opens.

Signature

I don't check the Email account attached
to this message.     Send instead to...
RBrandt    at       Hunter      dot      com

 
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.