Custom Format

basilyos

Registered User.
Local time
Today, 02:08
Joined
Jan 13, 2014
Messages
256
hello guys

i have a table "tbl1" that contains a field named "Movie_Size" (Data Type = Short Text)

in my form i have 2 text boxes

first text box unbounded named "Movie_Size1"

second textbox named "Movie_Size" bounded to "Movie_Size" in tbl1

in the first text box i will type the movie size as it shown in my computer for example 999999

in the after update event of the first text box i put this code

Code:
If Me.Movie_Size1.Value <= 999999 Then
Me.Movie_Size.DecimalPlaces = 0
Me.Movie_Size.Format = "# MB"
Me.Movie_Size.Value = Me.Movie_Size1.Value / 1024
ElseIf Me.Movie_Size1.Value > 999999 Then
Me.Movie_Size.DecimalPlaces = 2
Me.Movie_Size.Format = "#,## GB"
Me.Movie_Size.Value = Me.Movie_Size1.Value / 1048576
End If

so the second text box will result the movie size in mb or gb

for example

txtbox1 = 954211
txtbox2 = 932 MB but instead of (932 MB) i'm getting this result 931.8466796875


if i change the data type in the table to number it will fix the problem but i cant add the (MB) or (GB)

any solution?????
 
In the table you should save the real data, as long number.

On forms and reports you can show it as you like.
round(field) & "mb", is one option
 

Users who are viewing this thread

Back
Top Bottom