472,332 Members | 1,142 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,332 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 9126
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...
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...
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...
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...
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 ?...
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...
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...
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...
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...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...

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.