Set a Default

G

Greg

I have a form in which I set the Rowsource of a combobox with a function. I
also need to set the default to the first row of the recordset produced by
the function ?

ie

Section_ID.RowSource = Sections_by_Type(Structural_Type_ID,
Me.Structural_Grade.Value)
'Section_ID.DefaultValue = ????????
 
P

Piet Linden

I have a form in which I set the Rowsource of a combobox with a function.I
also need to set the default to the first row of the recordset produced by
the function ?

ie

Section_ID.RowSource = Sections_by_Type(Structural_Type_ID,
Me.Structural_Grade.Value)
'Section_ID.DefaultValue = ????????

then you have to use MoveFirst and then grab the value of the field...
rs.Fields("FieldName").Value
 
M

Marshall Barton

Greg said:
I have a form in which I set the Rowsource of a combobox with a function. I
also need to set the default to the first row of the recordset produced by
the function ?

Section_ID.RowSource = Sections_by_Type(Structural_Type_ID,
Me.Structural_Grade.Value)


Section_ID.DefaultValue = """" & Section_ID.ItemData(0) &
""""

But the DefaultValue property is only applied at the time of
the first keystroke/selection on a new record so it may be
too late for it to have an effect on the current record.

You can set the value for the current record using:

Section_ID.DefaultValue = Section_ID.ItemData(0)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top