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

Displaying First Item in ComboBox

Status
Not open for further replies.

Ajb2528

Technical User
Feb 22, 2002
270
GB
Hi all!!

I need help on comboboxes in Access V7!

I have an unbound combobox that uses the following as the recordsource:-

SELECT DISTINCTROW [tblBankRecLastBalance].[StartBalDate] FROM [tblBankRecLastBalance];

with a Row Source Type of:- Table/Query

my problem is that when the form loads, I need the first entry to be displayed and the value placed into a variable

I have tried using listindex=0 but this just reutrns an error!!!!

Can anyone help??

Regards,

Alan
 
Hi,
Try the following:

Private Sub Form_Load()
Me.Combo0.SetFocus
Me.Combo0.Text = Me.Combo0.ItemData(0)
comboVar = Me.Combo0.ItemData(0)
MsgBox comboVar
End Sub Hope it helps. Let me know what happens.
With regards,
PGK
 
Hi pgk!!!

Thanks for replying so quickly!!

It worked fine after some minor twiddling!! Here is the slightly modified code...

Dim comboVar

Me.cboStartDate.SetFocus
Me.cboStartDate.Value = Me.cboStartDate.ItemData(0)
comboVar = Me.cboStartDate.ItemData(0)
MsgBox comboVar

Regards,

Alan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top