Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old November 4th, 2004, 03:05 PM
Friend of Wrox
Points: 4,007, Level: 26
Points: 4,007, Level: 26 Points: 4,007, Level: 26 Points: 4,007, Level: 26
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Lansing, Michigan, USA.
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default DefaultValue Property Setting Failing

What could cause the assignment of a default value to a text box or combo box in Access XP VBA to give a #Name? error? For example, I have a very simple declaration of

Me.txtMyField.DefaultValue = "Whatever"

When I open the form, instead of the default I specified, I'm getting the #Name? error in the text box. I'm getting the same error in a combo box in another form. Both syntaxes are quite simple and they are correct.

What gives?


Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
__________________
Greg Serrano
Michigan Dept. of Environmental Quality
Air Quality Division
Reply With Quote
  #2 (permalink)  
Old November 6th, 2004, 05:51 AM
Authorized User
 
Join Date: Jul 2003
Location: Stockton on Tees, , United Kingdom.
Posts: 73
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It seems .DefaultValue only works on a bound textbox not an unbound one.

Cheers Ray
Reply With Quote
  #3 (permalink)  
Old November 8th, 2004, 08:22 AM
Friend of Wrox
Points: 4,007, Level: 26
Points: 4,007, Level: 26 Points: 4,007, Level: 26 Points: 4,007, Level: 26
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Lansing, Michigan, USA.
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

Actually, my fields are bound. Here is how this is solved. It makes no sense to me, but it works.

Me.txtMyField.DefaultValue = "'Whatever'"


Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
Reply With Quote
  #4 (permalink)  
Old April 2nd, 2007, 12:22 PM
Registered User
 
Join Date: Apr 2007
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default


<quote>
Actually, my fields are bound. Here is how this is solved. It makes no sense to me, but it works.

Me.txtMyField.DefaultValue = "'Whatever'"
</quote>

Um... how is the solution different than the original problem code?


I'm having a similar problem. I have a bound field on a form, and I'm just trying to set its DefaultValue from the form's open event code:

Me.ProcurementTitle.DefaultValue = "hi"

This gives me #Error instead of "hi" when I open the form. Funny thing is I'm doing exactly the same thing on another form with another bound control and it works fine. Also, if I set DefaultValue to "hi" in the property sheet instead of from code, it works fine (I get "hi" instead of #error). Anyone know what's going on?




Reply With Quote
  #5 (permalink)  
Old April 2nd, 2007, 12:23 PM
Registered User
 
Join Date: Apr 2007
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

 
Quote:
quote:Um... how is the solution different than the original problem code?


Sorry, stupid me I missed the single quotes.

Reply With Quote
  #6 (permalink)  
Old April 2nd, 2007, 12:40 PM
Registered User
 
Join Date: Apr 2007
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default


Figured it out. In my case, the main problem was that my string data had a bunch of trailing spaces, so I had to use trim.

For the rest of you, the solution is to concatenate the double quotes in code. I have no idea when the double quotes are and and are not required, since I am doing it both ways in separate places with no obvious differences.

This is what worked for me:
Me.ProcurementTitle.DefaultValue = Chr(34) & Trim(strResult) & Chr(34)
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting property value of class - objectdatasouce ranjan74feb ASP.NET 2.0 Professional 0 October 20th, 2007 03:51 AM
Setting "DBEngine.SystemDB" property jkuusik BOOK: Access 2003 VBA Programmer's Reference 2 December 28th, 2005 05:51 AM
Setting Property for a Custom Control cadaats C# 0 October 17th, 2005 02:22 AM
Setting ReadOnly Property Values Gavin265 General .NET 8 May 19th, 2005 12:49 PM
setting the ReadOnly property with a function creative_eye General .NET 3 May 10th, 2004 03:27 PM



All times are GMT -4. The time now is 05:02 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.