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

Me!listBox.Selected(0) = True >>> CRASH

Status
Not open for further replies.

smandoli9

Programmer
Jun 10, 2002
103
US
Access 2003. My form starts with a list box, populated via code:

[blue]Me!BOM_RollUp_sub.Form![listBOM].RowSourceType _
= "Table/Query"
Me!BOM_RollUp_sub.Form![listBOM].RowSource _
= "SELECT etc ..."[/blue]

Selecting one of its records populates the rest of the form. I want the topmost of the listbox records to be the default selection. For weeks I have searched for a way to set a default selection ... TekTips suggested adding:

[blue]Me!BOM_RollUp_sub.Form![listBOM].Selected(0) = True[/blue]

This produces what I want. But when I close the form, the app crashes: [red]Microsoft Access has encountered a problem and must close. We are sorry, privacy statement, etc. ... [/red]

If I comment out my new line of code, no problem. Now why would this single line of code, upon form close, crash the app ?!




_______________________________
Never confuse movement with action -- E. Hemingway

_______________________________
 
Which event, on the main form, is the code in?
Could it have anything to do with, the order of Events on close?

I doubt it offhand, but just in case?

Good luck either way!
 

The code is in Form_Open. Also the problem has changed shape a bit. The form now crashes more quickly ... eliciting this crash is tedious and I'll just say apparently if I touch the form after it's loaded, app crashes. That's a bit less spooky anyway.

I think I'll pursue this as an Access Weird Glitch: make a new blank database, import all objects, decompile.

[purple]_______________________________
Never confuse movement with action -- E. Hemingway [/purple]
 
No luck. I did get it to act in the old (spooky) way. Any help appreciated. My workarounds at this moment are sillier than the problem.

[purple]_______________________________
Never confuse movement with action -- E. Hemingway [/purple]
 
Whoa! The same posting that gave me my "Bomber Code" also had:

[blue]Me!BOM_RollUp_sub.Form![listBOM] _
= Me!BOM_RollUp_sub.Form![listBOM].Column(1, 0)[/blue]

which did nothing. So I tweaked:

[blue]Me!BOM_RollUp_sub.Form![listBOM].[maroon]Value[/maroon]
= Me!BOM_RollUp_sub.Form![listBOM].Column(1, 0)
[/blue]

I now have a workable result -- record selected, no crash.

[purple]_______________________________
Never confuse movement with action -- E. Hemingway [/purple]
 
Good to know smandoli9, Thanks!

(Who would've thought?)
 
Unfortunately I am going to have to rebuild this whole form and I'm bummed.




[purple]_______________________________
Never confuse movement with action -- E. Hemingway [/purple]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top