.DefaultValue Help again

  • Thread starter Thread starter Andrew
  • Start date Start date
A

Andrew

Some one told me to use this code:

Use code in the control's AfterUpdate event along the
lines of:

Private Sub Account_Name_AfterUpdate()

With Me![Account Name]
.DefaultValue = """" & .Value & """"
End With

End Sub

On using this code, when I open a new record, in the
combo box [Account Name] there is no default value, and
it will not let me select anything from the list. When I
close the record and open it again, then I can select
something from the list. Is there something that I am
missing? This is what I was trying to do:

I have a Combo Box Called [Account Name]. Whant I want to
 
Private Sub Account_Name_AfterUpdate()
With Me![Account Name]
.DefaultValue = """" & .Value & """"
End With

End Sub

On using this code, when I open a new record, in the
combo box [Account Name] there is no default value, and
it will not let me select anything from the list. When I
close the record and open it again, then I can select
something from the list. Is there something that I am
missing?

Make sure that the field that the combo box is bound to is a text field. If the
combo box has two columns consisting of an ID field and a DESCRIPTION field, for
example, and the bound column is 1, the value stored is a number (the ID value),
not the displayed text. Or, you can simply try:

Me.[Account Name].DefaultValue = Me.[Account Name].Value

.... and see if that works.
 
Bruce M. Thompson said:
Private Sub Account_Name_AfterUpdate()

With Me![Account Name]
.DefaultValue = """" & .Value & """"
End With

End Sub

On using this code, when I open a new record, in the
combo box [Account Name] there is no default value, and
it will not let me select anything from the list. When I
close the record and open it again, then I can select
something from the list. Is there something that I am
missing?

Make sure that the field that the combo box is bound to is a text
field. If the combo box has two columns consisting of an ID field and
a DESCRIPTION field, for example, and the bound column is 1, the
value stored is a number (the ID value), not the displayed text. Or,
you can simply try:

Me.[Account Name].DefaultValue = Me.[Account Name].Value

... and see if that works.

Bruce, that's not necessary. The code posted (by me, as it happens)
will work no matter what type of field the combo box is bound to.
Something else is going on here.
 
Bruce, that's not necessary. The code posted (by me, as it happens)
will work no matter what type of field the combo box is bound to.
Something else is going on here.

Oh yeah. It's "the other way around" that doesn't work. <g>

Sorry about that.

:-)
 
Back
Top