?
Solved

AfterUpdate event not working properly

Posted on 2012-03-21
3
Medium Priority
?
365 Views
Last Modified: 2012-06-27
I have a combobox on a form and for the afterupdate event I have:

Me.comboboxname.defaultvalue = me.comboboxname

But then when a new record is entered using the form, which has not been closed, I do not get the value of the previous record in the combobox.  Instead I get #Name?

What is wrong with the code?

--Steve
0
Comment
Question by:SteveL13
3 Comments
 
LVL 26

Accepted Solution

by:
Nick67 earned 2000 total points
ID: 37747994
DefaultValue wants a string
me.comboboxname is the actual control.
Now, it should coerce to Me.comboboxname.Value, but it may not be

Troubleshooting steps
1. Try Me.comboboxname.defaultvalue = "SomeValidValue" where SomeValidValue is something that makes sense in your context, a valid value for the combo box.  You can then see if you are even able to set DefaultValue in the event the way you want to.

2. Next Put msgbox me.comboboxname.value into the code.  Have a look at what is actually being spat out by me.comboboxname.value. Is it what you expected?  Will it make sense as a default in the next new record?

3. If it is a number, you may be being bit by the fact that DefaultValue wants a string.  Try
Me.comboboxname.defaultvalue = chr(34) & me.comboboxname.value & chr(34) to wrap the value in quotes so that it is recognized as a string value.  This problem can crop up quite frequently when using control values as VBA variables.  It is most times not enough to just supply the value when a string is desired.  The delimiters are also needed.  The same thing can happen with dates, when the explicit #somedate# hash marks are needed
0
 
LVL 31

Expert Comment

by:Helen Feddema
ID: 37748027
What are you trying to do?  As stated, your question doesn't seem to make sense.  What is the purpose of this combo box?
0
 
LVL 31

Expert Comment

by:hnasr
ID: 37748155
Unable to reporduce your issue.
It is working fine with me using your code.
Check the code to make sure you are using the proper names.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question