473,395 Members | 1,670 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,395 software developers and data experts.

default value

n8kindt
221 100+
consider this scenario:

there are 2 text boxes in a form. "Text1" is unbound. "Text2" is also unbound.

Text2, however, has its default value set to: =Nz([Text1],0) + 8

let's say a user types "2" into Text1. what vba command do i use to to "refresh" Text2 to properly display its current default value of "10"??

i know this seems like a stupid question but i couldn't immediately find anything by searching :-/... could someone kindly point me in the right direction?

thanks guys,
nate
Apr 2 '08 #1
4 1165
Scott Price
1,384 Expert 1GB
Expand|Select|Wrap|Line Numbers
  1. Me.Repaint
should do it.

Regards,
Scott
Apr 2 '08 #2
n8kindt
221 100+
Expand|Select|Wrap|Line Numbers
  1. Me.Repaint
should do it.

Regards,
Scott
thanks for your reply, scott. hmmm i tried placing that code in the AfterUpdate, GotFocus, and Change events of both text boxes and nothing seems to happen. i'm guessing Me.Repaint will refresh the textbox in which the OnEvent code is placed. so if i placed this code in a Text1 Event, wouldn't i need a separate code for Text2? what i'm thinking is i need a code to place in the AfterUpdate event of Text1 which repaints Text2.

something tells me there's a better way to do this strictly through vba--bypassing the default value thing. something like
Expand|Select|Wrap|Line Numbers
  1. text2.value = text1.value + 2
(try not to laugh too hard at my feeble attempt at generating vba code with only a small knowledge of the language :) )...
as is, i don't think that code would return anything and also, i have no idea where to place that code once it works.
Apr 3 '08 #3
n8kindt
221 100+
ok, i figured it out. that's funny, i guessed right!

for future reference, this is the code i used
Expand|Select|Wrap|Line Numbers
  1. Private Sub Text1_AfterUpdate()
  2. Text2.Value = Text1.Value + 2
  3. End Sub
Apr 3 '08 #4
Scott Price
1,384 Expert 1GB
You're doing fine :-)

I think your solution is better also...

Glad you figured it out!

FYI when in the VBA editor window, position the cursor within any word and press F1 to bring up the specific help topic for that word... You probably know this already, but just in case.

Regards,
Scott
Apr 3 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

29
by: John Wood | last post by:
Even though CSC does its best to detect use of unassigned variables, it often misses it... for example if you just declare a double in a class without assigning a default value, it has a default...
74
by: Zytan | last post by:
I have a struct constructor to initialize all of my private (or public readonly) fields. There still exists the default constructor that sets them all to zero. Is there a way to remove the...
23
by: Jess | last post by:
Hello, I understand the default-initialization happens if we don't initialize an object explicitly. I think for an object of a class type, the value is determined by the constructor, and for...
4
by: Jess | last post by:
Hello, I tried several books to find out the details of object initialization. Unfortunately, I'm still confused by two specific concepts, namely default-initialization and...
10
by: Brad Baker | last post by:
I have an asp.net/csharp application that requires a particular variable to work properly. This variable is usually passed via a query string in the URL when the application is first run but under...
4
by: Macneed | last post by:
i am a newbie, i remember i read a book talking about when u declare a array variable using float ABC = new float; the whole array element in ABC ( ABC to ABC ) will automatic initialize to 0...
4
by: Dave Burns | last post by:
Hello, I am trying to specify a logical default value for a in a WCF Web Service using basicHttpBinding. I realize that the language defaults are: int - 0 string - null bool - false
7
by: =?Utf-8?B?Y291Z2FyaXN0aWM=?= | last post by:
I am trying to convert an C# application to VB and have one issue which is converting the generic value to the default. C# uses return default(T) as the return value how would I translate this in...
43
by: kenneth | last post by:
Dear all, I have encountered this weird problem. I have a class definition with an __init__ argument 'd' which defaults to {}. This argument is put in the 'self.d' attribute at initialization...
9
by: lawpoop | last post by:
I'm trying to write some simple code, but I might be simplifying it too much. I have a function that either returns a string that I want, or FALSE. In the code that I'm working on, I would like...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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:
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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
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...

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.