473,554 Members | 2,339 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Defa ultValue = 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 9198
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.c om> wrote in message
news:2j******** *******@newssvr 14.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.Defa ultValue = 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.c om> wrote in message
news:2j******** *******@newssvr 14.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.Defa ultValue = 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
2200
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 here it don't exists. How can I resolve this problem? Tkx; Nic
2
3484
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 Label. It jams all the text together into one continuous line of text. Is there a way to display the data like a textbox, but not look like a text...
0
1062
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 property like this: private int widthTextBox; //*** public int WidthTextBox
3
1993
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 been entered there. First, I used Me!TowFee.DefaultValue = Null That returned an error, so I used Me!TowFee.DefaultValue = ""
10
3275
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 { return showDropDownButtons; }
6
9378
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") DefaultValue("bool","true")
1
1905
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: <DefaultValue("0")> _ Public Overrides Property Text() As String Get Return MyBase.Text End Get Set(ByVal...
5
2150
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 what i set as a defaultvalue in the beginning. how will i get this to work? i want the defaultvalue of my datatable to change to what is placed in...
3
8433
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
7612
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7536
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7814
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7895
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6163
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5165
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3583
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2027
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
853
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.