Question

I lookud up information about this topic, but without any effect.

I have a Access' table called TbKlient, which contains columns ID (primary key, autonumbered) and Name (Name of the Company) and Form FormVT1 with combobox cbName. My aim is simple but I can't achieve this. So I want, when I open this form, auto populate default value of cbName combobox with first row of TbKlient's Name column.

Appreciate all sugestions. Thank you!

Was it helpful?

Solution

Try to assign onOpen event form form FromVT1

Private Sub Form_Open(Cancel As Integer)
dim rst as recordset

set rst=currentdb().openrecordset("SELECT [Name] FROM [TbKlient] ORDER BY [ID]") ' author, please check if you really want record with the lowest ID that is called by you "first record"

if not rst.eof then

    Me.cbName.DefaultValue = rst![Name] 

end if 

rst.close
set rst=nothing

end sub
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top