Solved

AfterUpdate event not working properly

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
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.

760 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

16 Experts available now in Live!

Get 1:1 Help Now