Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

AfterUpdate event not working properly

Posted on 2012-03-21
3
Medium Priority
?
363 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

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

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

636 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