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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Load form from switchboard gives different result??

Status
Not open for further replies.

gusbrunston

Programmer
Feb 27, 2001
1,234
US
I thought I knew all about displaying a default value in a combo box when loading the form! In properties, I have:

Default Value....[MyComboBox].[ItemData](0)

And that works, when I open the form from the database window. But when I load the form from the main switchboard, MyComboBox is left empty. Why is there a difference when the form is loaded from the switchboard and when it is opened from the database window? Anybody?
Thanks, s-) Gus Brunston
An old PICKer
padregus@home.com
 
Hi Gus,
Opening a form to show the value that's in another forms combo but from the switchboard would take something in the on Open event of the second form like:

If IsLoaded("NameOfTheFirstForm") Then
Me.SomeField.DefaultValue = Forms!NameOfTheFirstForm!NameOfCombobox
End if

The IsLoaded Function comes from the Module "Utility Functions" in the Northwinds Sample database and is indispensable. It tests if the form in question is...loaded!

Simply opening a form and setting a default value would have to be set in the fields Default Value property:

="This Value" Or 12345 or refering to another control on the same form =[SomeOtherControl] .

You may have to requery the combo box in this case with something like:

Me.ComboBoxName.Requery

Hope one of these ideas will get it to run... :) Gord
ghubbell@total.net
 
Dear Gord:
Thanks for your reply.

Well...this is how I did it:
In a macro that runs "On Open" I added "GoToControl" and named the combo box. Then, in the property sheet for the combo box, "On Got Focus", I put a macro with just "requery" in it. So...

When the form opens, the combo box gets the focus;

When the combo box gets the focus, it requeries.


Sounds kind of Rube Goldberg, doesn't it. But it works. I imagine there are neater ways to do this using code, but I don't know much about coding yet. I suspect that with further messing around, I'll find that the first step may not be necessary (giving the combo box the focus). :cool:

Gus Brunston
An old PICKer
padregus@home.com
 
Well! I got a bonus. Before I did that Rube Goldberg stuff with the macros, I couldn't get the combo box to show the added records until I exited the form and reopened it. Now the new records show up in the combo box right away. X-) Gus Brunston
An old PICKer
padregus@home.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top