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

SELECT FIRST OPTION OF COMBO BOX AUTOMATICALLY

Status
Not open for further replies.

fsweb2002

Programmer
Apr 11, 2002
94
TR
Hi there

I have a combo box which is populated via SQL.
After the SQL runs, I want it to select the first record on the list...

I have tried mycmbbox=mycmbbox.ItemData(0) as I believe this is the way to do it (from other messages on the forum) HOWEVER this doesn´t seem to work correctly.

IS there some other way of doing it ???

Thanks
 
Hi,
Try the following in the Load event of the Form:


Me.Combo0.SetFocus
Me.Combo0.Text = Me.Combo0.ItemData(0)
Call Combo0_AfterUpdate Hope it helps. Let me know what happens.
With regards,
PGK
 
thanks for the input pgk

Sorry, it didn´t work...

it gives me a "NULL VALUE not VALID (Error 94)" (sorry, I use a spanish version of Access so I am not sure if I translated the error description correctly...)

The error happens on the following code line...

Me.Freight3Desc.Text = Me.Freight3Desc.ItemData(0)

Any other ideas???
 
Hi there

The error 94 I was getting was related to something else...

I´ve just put the following on its own and it seems to work !

Me.Freight3Desc = Me.Freight3Desc.ItemData(1)

But I had also tried the following last weekend and it didn´t work. Now I´ve used it again and IT WORKS.
Freight3Desc = Freight3Desc.ItemData(1)

Is Access known for doing things "as it feels like it"?





 
It would seem so. In a database that I wrote several months ago in Access 97, things seem to work fine, even when I try to run them in Access XP (converted, obviously). However, when I try to write my new database using identical code, it doesn't accept it.

I hate Microsoft.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top