Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help/assistance with combo boxes remembering values....

Status
Not open for further replies.

cavery

Technical User
Oct 29, 2002
129
0
0
US
I have a combo box (cbomodel) that stores values of model names. When I toggle in between forms, I want the combo box to remember the last value that was selected, in order to maintain consistency with my users.

So far I've used:
If statement...
strmodelold = me.cbomodelname

else
me.cbomodelname = strmodelold

That doesnt seem to work. In addition I've placed this line of code in the cmdbutton that toggles in between forms. i.e cmdviewmodel.

Any help or suggestions would be appreciated.
Thanks!
Clark


~Clark
 
Clark,

I believe it already does that. Your combo box either puts it's results in a field (and from form to form) tries to follow that field. If it puts its value no where - which means that you answereed the wiz, "I will use the value later" or some such, it will stay where you put it.

I beleive it is more 'stable' to do the later. Thus I put the value in an unbound text box and uses/ see it whenever I wish.

rollie@bwsys.net
 
You could create a Public variable to hold the value. Let say you use pbModel for the variable name.

Then in the AfterUpdate event of cbomodelname:

pbModel = Me!cbomodelname

Now when you are in any other form, you can use gvModel as the model number.

Hope this helped!

Anthony J. DeSalvo
President - ScottTech Software
"Integrating Technology with Business"
 
I'm still having trouble with seeing the same model# appear after I change forms. I thought I would use the public variable before, so that was a simliar idea. But I wasnt using the bang (!) operator, thought that was the problem but it wasnt. I did place the code in the afterupdate property but nothing so far.

Any more suggestions?

I know this is pretty easy and I'm probably making it more hard for myself!

Thanks alot!
~Clark

~Clark
 
Put the public variable in a module -
Public MyVariable as variant

In the on_current event of the form to put that variable in a text box named text0

me.text0 = MyVariable

That is all. As each record comes up, the me.text0 box will show your variable. Is that what you want??

rollie@bwsys.net
 
Actually I found my problem, I was resetting the values based on a duplicate dlookup....it works fine now. Thanks for all the help and suggestions!

Clark

~Clark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top