0
votes

I created a form in MS Access 2007 for updating the user records in it.
I have one combobox in that form. I want to make one value as default. I'm selecting only one column from the query.

When the form loads it shows my default value. After submitting one record using button click it changes to the last value I selected for updating the record.

I want to show the same default value every time.

Query:

Public function bindcombo()
    Rs as recordset
    Strqry ="select menuname from menumaster wher menutyp='cutback'"
    Rs.open strqry
    With cbocutback
        .clear
        .RowSourceType = "table/query"
        .RowSource =strqry
        .ReQuery
        .defaultvalue="NA"
    End with
End function

I get the value in the combobox, and it is not showing my default value there. It is showing "#Name?" (THIS VALUE INSTEAD OF THE DEFAULT VALUE)

These are my combobox values: rcCutback, loc-cutback and NA.

1
If you always want the default value to be "NA" why not just set it to that on the form control, and not bother with the code ? I can't see any need for all the code at all at the moment, unless this isn't the whole story. Also your With clause isn't referencing the combobox as far as I can see either.Minty
I tried using the property box also. Its coming when the form is opening. After submitting one record it's changing to the last value i have selectedShinilrk
Let me guess - is this a continuous form ?Minty
If it's unbound then you can't have different values on a continuous form, as it's got no field value to refer to, so your value will apply to every instance of the control. If it's able to be bound to a underlying value then it will workMinty
Hi Minty, Can you please explain thisShinilrk

1 Answers

0
votes

In Combobox's AfterUpdate property set the default value again.

Private Sub COMBOBOX_AfterUpdate()
    COMBOBOX = "NA" 'or any value you want to set COMBOBOX to

End Sub