A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Set combo box default value



 
 
Thread Tools Display Modes
  #1  
Old January 9th, 2008, 08:07 PM posted to microsoft.public.access.forms
Sajit
external usenet poster
 
Posts: 32
Default 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  
Old January 9th, 2008, 08:16 PM posted to microsoft.public.access.forms
Jeff Boyce
external usenet poster
 
Posts: 8,621
Default 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  
Old January 9th, 2008, 08:18 PM posted to microsoft.public.access.forms
Klatuu
external usenet poster
 
Posts: 7,074
Default 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  
Old January 9th, 2008, 08:47 PM posted to microsoft.public.access.forms
Sajit
external usenet poster
 
Posts: 32
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 01:21 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.