Default value will not change. Why?

G

Guest

I have the following code in my OnLoad event on my form. It works perfectly
except it changes everything to "Pending" when the form opens. I need to
haved "Pending" which is number 9 (associatied with pending) be the default
on my cbo. If the user wants to change the selection they can but not have
pending for all records when the form opens. How can I do this? Please help!

Me.InsuranceConsultant.Value = Me.InsuranceConsultant.ItemData(2)
 
K

Ken Snell \(MVP\)

You're setting the value of the combo box, not its default value.

Me.InsuranceConsultant.DefaultValue = Me.InsuranceConsultant.ItemData(2)


Also, use the form's Load event to do things like this. During the Open
event, many controls, fields, and data are not available to the form and you
may not get the results you want.
 
G

Guest

It is strange. The other event I was using worked and I cant get anything
from your code. Nothing shows up. Any other ideas? that is strange though
 
K

Ken Snell \(MVP\)

What are you expecting from the code I posted? It will set the Default Value
of the Consultant control so that new records will have that value in the
Consultant control when the new record is initially created. It will have no
effect on existing records.

Perhaps what you want to achieve is not a default value? Please give us more
information about what you want to happen on your form -- and whether the
form is showing existing records, or just new records, or what.
 
G

Guest

Ken, don't get frustrated
TKM asks a lot of questions and never seems to quite understand the answers
or doesn't like the answers because they don't fit with what he wishs it
would be.
 
B

BruceM

Is it a bound or an unbound combo box? What is its purpose?

Would it help to know that if the combo box is bound to a field in the
underlying table, DefaultValue applies only to new records? If
InsuranceConsultant is unbound, DefaultValue will appear until somebody
changes it, at which point it will show the new value until somebody changes
it again. Moving from one record to another will not affect it, unless you
have code (in the form's Current event, for instance) to change the value.
 
G

Guest

No I do appreciate the answers. However I am supporting a application that is
very involved which has a script to gnerate the rollout which never works,
SQL statments in 3 tables whihc code fires. Not just one piece of code at
least 2 and sometimes 3. I have 2 others here that try and work with this
application howver the other developer has it so complicated that it is hard
to explain what we are looking for. Why? Because sometimes we dont even know.
I know that is not what you wanted to hear but the boad does give us a start
and that sometimes is good enough.
 
G

Guest

Ken,

Thanks for the info. Yes I am looking to have the 3rd seleciton in our combo
box as the default. If the user does not select anything then the record will
have that default in the table. I understand it is for new records only as I
tested as such. However nothing happends and no value is placed in the table.
I could be because so many other properites, code (forms and controls) with
expression could prevent this from happening. Thank you very much for the
response and I do appreciate all your help.
 
K

Ken Snell \(MVP\)

To more fully debug why this is not working, we'd need to see the full code
that is running in the form's Load, Open, BeforeUpdate, and BeforeInsert
events.

I know that this code syntax will work, if names are correct, etc., because
I use it in many of my applications in the Load event of a form.
 
A

AccessVandal via AccessMonster.com

Hi TKM,

From what I have read in your post, It seems that you want to run the code in
the form's OnLoad Event
automatically fill the combo box with the word "Pending" as the default
choice.

If the combo box is bound to the record, the chances are that the bound combo
will always change the record whenever the form is loaded.

What you need is a unbound combo box that will always shows the word
"Pending".
Use the unbound combo box to auto fill the textbox instead.
 

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