473,414 Members | 1,980 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

Set DefaultValue of Textbox with VBA - why doesn't it stick?

If I set the DefaultValue of a Textbox in the properties sheet of the
control, it sticks after I close and reopen the form. But if I try to set
it with code:

Me!txtPath.DefaultValue = Chr(34) & Me!txtPath & Chr(34)

The Textbox reverts back to blank after I close and reopen the form. Am I
missing something? The help file says it's read/write...
Nov 13 '05 #1
5 9186
No, you can only make it stick if you change the value in design view of the
form and then save the form. And your code doesn't open the form in design
view.

The property is "read/write", which is why you can change its value while
the form is open. But changing a value does not save the value.

--

Ken Snell
<MS ACCESS MVP>
"deko" <de**@hotmail.com> wrote in message
news:2j***************@newssvr14.news.prodigy.com. ..
If I set the DefaultValue of a Textbox in the properties sheet of the
control, it sticks after I close and reopen the form. But if I try to set
it with code:

Me!txtPath.DefaultValue = Chr(34) & Me!txtPath & Chr(34)

The Textbox reverts back to blank after I close and reopen the form. Am I
missing something? The help file says it's read/write...

Nov 13 '05 #2

"deko" <de**@hotmail.com> wrote in message
news:2j***************@newssvr14.news.prodigy.com. ..
If I set the DefaultValue of a Textbox in the properties sheet of the
control, it sticks after I close and reopen the form. But if I try to set
it with code:

Me!txtPath.DefaultValue = Chr(34) & Me!txtPath & Chr(34)

The Textbox reverts back to blank after I close and reopen the form. Am I
missing something? The help file says it's read/write...

Ken Snell's answer describes the problem well, but if you are looking for a
solution to this, there are a number of options - you just need to decide
where to store this setting. Ideas include a registry entry, a local
settings table, a custom property of the form, an ini (or other plain text )
file.
Nov 13 '05 #3
> No, you can only make it stick if you change the value in design view of
the
form and then save the form. And your code doesn't open the form in design
view.

The property is "read/write", which is why you can change its value while
the form is open. But changing a value does not save the value.


I see. Thanks for the tip.
Nov 13 '05 #4
> Ken Snell's answer describes the problem well, but if you are looking for
a
solution to this, there are a number of options - you just need to decide
where to store this setting. Ideas include a registry entry, a local
settings table, a custom property of the form, an ini (or other plain text ) file.


I tried Me.Tag, but apparently that works the same as DefaultValue. I've
done other databases with a settings table, but with this one it's only one
string. Still, it saves the user a lot of work - otherwise he has to
navigate and drill into the directory structure to repopulate the path
variable each time. A custom form property sound interesting. Are there
any concerns with different versions/service packs? The users in this shop
are some of the worst.
Nov 13 '05 #5
> The table is your best bet here, deko. The problem with using a
custom form property is the same as with any other change to the form,
you have to allow the users to change the form when they close it.
Which can cause other problems.


10-4. Thanks for the tip.
Nov 13 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Nic | last post by:
Hey, I have an ASP-application. In the ASPX I have an <asp:dropdownlist ..>. Now when I leave this control I want to initialisize some other fields. In window forms we uses the onleave event but...
2
by: tshad | last post by:
I have a screen that is displaying an asp:textbox that has about 20 lines of text with line feeds that I read out of my Database. This displays fine as a multiline textbox. It doesn't as a...
0
by: dan | last post by:
Hi NG, i am developing an asp.net Custom control which consist of some TextBoxes, Button, ... . To let the user of that control set for example the width of the TextBox, the class has a...
3
by: MLH | last post by:
On frmVehicleEntryForm... I wanted to change the DefaultValue property of one of my textbox controls on a form from within code. I wanted the setting to be no setting - as if nothing had ever...
10
by: tony | last post by:
Hello!! I have some demo programs written in C# and they have this construction "" see below. I haven't seen this before so what does it mean ? public bool ShowDropDownButtons { get {...
6
by: Peter Hartlén | last post by:
Hi! What's the correct syntax for the default value design time attribute, using classdiagram view and Custom Attributes dialog. For a boolean: DefaultValue(true) DefaultValue("true")...
1
by: daleykd | last post by:
Hello all. I've been pulled out my hair all day trying to figure this one out. In VB .NET 2.0, I'm attempting to create a custom control inheriting a TextBox. I've attempted to do a: ...
5
nev
by: nev | last post by:
my datatable column defaultvalue depends on what is displayed on a textbox. but i noticed that you can only set the defaultvalue once because when i set it again, the defaultvalue remains the same as...
3
by: Johnny Jörgensen | last post by:
Does anybody know how to correctly specify the defaultvalue attribute for a property whose type is an enum. Example: Public Enum TestValues Value1=1 Value2=2 End Enum
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.