If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Set combo box default value
I am trying to set the default value of a combo box to the last value with
which the form was closed with. I was expecting this setting in the 'on form close' to work much the same way it would if I were to enter the default value in the properties manually. Private Sub Form_Close() Forms![list of standards]![Text25].DefaultValue = """" & Forms![list of standards]!Text25 & """" Debug.Print Me.Text25.DefaultValue End Sub But it does not. Why does the setting that I do, don't stick in there? Sajit Abu Dhabi |
#2
|
|||
|
|||
Set combo box default value
Sajit
I'm wondering if the "Close" event of the form is really where you want this to happen. There's a chance that this gets triggered too late... Regards Jeff Boyce Microsoft Office/Access MVP "Sajit" wrote in message ... I am trying to set the default value of a combo box to the last value with which the form was closed with. I was expecting this setting in the 'on form close' to work much the same way it would if I were to enter the default value in the properties manually. Private Sub Form_Close() Forms![list of standards]![Text25].DefaultValue = """" & Forms![list of standards]!Text25 & """" Debug.Print Me.Text25.DefaultValue End Sub But it does not. Why does the setting that I do, don't stick in there? Sajit Abu Dhabi |
#3
|
|||
|
|||
Set combo box default value
That is because changes to the form are not being saved. To do this, you
will need to close the form using: Docmd.Close acForm, "MyFormName", acSaveYes However, this may not be a good idea. What is the value is no longer available when you open the form the next time? And, it will not work if a user closes the form using the red x or closes the application while the form is open. -- Dave Hargis, Microsoft Access MVP "Sajit" wrote: I am trying to set the default value of a combo box to the last value with which the form was closed with. I was expecting this setting in the 'on form close' to work much the same way it would if I were to enter the default value in the properties manually. Private Sub Form_Close() Forms![list of standards]![Text25].DefaultValue = """" & Forms![list of standards]!Text25 & """" Debug.Print Me.Text25.DefaultValue End Sub But it does not. Why does the setting that I do, don't stick in there? Sajit Abu Dhabi |
#4
|
|||
|
|||
Set combo box default value
Jeff, Dave,
With the DoCmd I should see the last value set in the default value properties, provided I close it through a close button that I would have to create. Perhaps I have to also remove the red x button from the user. I have done the 'on close' event for forms in VB6 and it does work by the red x or the close button that I had put in. Is there a work around for it in VBA for the event getting triggered for the red x 'close'. Sajit "Jeff Boyce" wrote: Sajit I'm wondering if the "Close" event of the form is really where you want this to happen. There's a chance that this gets triggered too late... Regards Jeff Boyce Microsoft Office/Access MVP "Sajit" wrote in message ... I am trying to set the default value of a combo box to the last value with which the form was closed with. I was expecting this setting in the 'on form close' to work much the same way it would if I were to enter the default value in the properties manually. Private Sub Form_Close() Forms![list of standards]![Text25].DefaultValue = """" & Forms![list of standards]!Text25 & """" Debug.Print Me.Text25.DefaultValue End Sub But it does not. Why does the setting that I do, don't stick in there? Sajit Abu Dhabi |
Thread Tools | |
Display Modes | |
|
|