.DefaultValue Help again

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
 
B

Bruce M. Thompson

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.
 
D

Dirk Goldgar

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.
 
B

Bruce M. Thompson

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.

:)
 

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

Similar Threads


Top