populate a txtBox with 41. (nothing after the .)

dogdays

Active Member
Joined
Apr 28, 2008
Messages
434
Office Version
  1. 2007
Access 2003 XP
I have a global string gstrEndLat, it is initialzed to "41. "
I have a txtBox txtEndLat that I wish to populate with the 41.
then place focus on the space to the right of the dot

gstrEndLat = "41. "
txtEndLat.value = gstrEndLat

Access, in its infinite wisdom, drops the dot and I end up with 41
I also tried 41.0 same result.
How can I do this?

tia Jack
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
See if this modification works:
Code:
gstrEndLat = "41. "
txtEndLat.Text = gstrEndLat
I think .Value is usually used for numbers, and .Text is usually used for strings.
 
Upvote 0
Thanks for the response, unfortunately the results are the same.

Jack
 
Upvote 0
Hmmm... Interesting. How is your text box formatted?
 
Upvote 0
It seems to work OK for me, in that it keeps the "." after the 41, though it does seem to drop the single space after the dot. That may be some sort of auto-trim thing.

Here is my code:
Code:
Public gstrEndLat As String

Private Sub Form_Load()

    gstrEndLat = "41. "
    
    txtEndLat.SetFocus
    txtEndLat.Text = gstrEndLat

End Sub

Have you declared your global variable in the same manner?
When are you running your code to set the value?
 
Upvote 0
I have the following code:

In module global
Global gstrBegLat As String

in frmTrip open event
gstrBegLat = "41. " ' dec pt followed by 4 spaces

in subfrmTrawl

Private Sub txtEndLat_GotFocus()
If txtEndLat.Text = "" Then
txtEndLat.Text = gstrBegLat ' gstrBegLat is "41. "
End If
End Sub

I stepped through the debugger and result txtEndLat.Text was "41"

I am thoroughly confused.

Jack
 
Upvote 0
Generally problems involving values come from the determinations.

Your determination of a String is most likely the cause

Usually strings (Strung Numbers) are used to define arguments within a sequeunce - for example pulling data from recordsets or sequencing alogrithms.

Try using Integer or Constant value

Alternatives

Dim "your value" as Integer
Dim "your value" as Long Integer
Dim "your value" as Char
Dim "your value" as Boolean
Dim "your value" as Const

If you want to define your output to a whole number then determine the value as an Integer - to include the point value, especially needed when refering to minus numbers, Long Integer.

If you are planning to perform complex calculations then try looking up the theory of Boolean for algebraic method.

If you are using the ouput for a TEXT format you should use Char (Character)

By simply changing the determination of your value you should be able to find the desired result

- Snippet from wikipedia - Definition String -

A string is generally understood as a data type storing a sequence of data values, usually bytes, in which elements usually stand for characters according to a character encoding, which differentiates it from the more general array data type. In this context, the terms binary string and byte string are used to suggest strings in which the stored data does not (necessarily) represent text.

- Snippet from wikipedia - Definition Integer -

The integers (from the Latin integer, which means with untouched integrity, whole, entire) are the set of numbers consisting of the natural numbers including 0 (0, 1, 2, 3, ...) and their negatives (0, −1, −2, −3, ...). They are numbers that can be written without a fractional or decimal component, and fall within the set {... −2, −1, 0, 1, 2, ...}. For example, 65, 7, and −756 are integers; 1.6 and 1½ are not integers. In other terms, integers are the numbers one can count with items such as apples or fingers, and their negatives, including 0.

- Snippet from wikipedia - Definition Character (Char) -

In computer and machine-based telecommunications terminology, a character is a unit of information that roughly corresponds to a grapheme, grapheme-like unit, or symbol, such as in an alphabet or syllabary in the written form of a natural language.
An example of a character is a letter, numeral, or punctuation mark. The concept also includes control characters, which do not correspond to symbols in a particular natural language, but rather to other bits of information used to process text in one or more languages. Examples of control characters include carriage return or tab, as well as instructions to printers or other devices that display or otherwise process text
 
Upvote 0
Jack

What's the data type of the field?

If it's numeric then Access is probably converting your string to a number.
 
Upvote 0
More than likely Norie

Just to expand on that - make sure that in your table design view that the field data type match the format on your text box also

Check the text box on your form and see what format it is in

Change the format of your textbox to Standard
 
Upvote 0

Forum statistics

Threads
1,213,520
Messages
6,114,101
Members
448,548
Latest member
harryls

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top