Set a Default

  • Thread starter Thread starter Greg
  • Start date Start date
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 = ????????
 
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
 
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)
 
Back
Top