Solved

AfterUpdate event not working properly

Posted on 2012-03-21
3
342 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 500 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 30

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

910 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now