Solved

AfterUpdate event not working properly

Posted on 2012-03-21
3
347 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

856 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