By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,027 Members | 1,261 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,027 IT Pros & Developers. It's quick & easy.

Fill field to the size of the field

P: 5
I have a table with 2 fields (Cost) and (CostTxt).
I need to update (CostTxt) with the value of (Cost), where (Cost) is 123 and (CostTxt) becames 000000000000123.
The size of field (CostTxt) is 15.
Aug 19 '08 #1
Share this Question
Share on Google+
3 Replies


hyperpau
Expert 100+
P: 184
I do not have access right now but I have done this in the past.

I amnot sure if it will work for you but try this.


Go to the design view of the table with the CostTxt and on the field CostTxt, apply a format and type 15 zero's ("000000000000000")

Then create an update query joining the two tables via the primary key and that primary key as the Criteria. Update the Costxt field with the value of Cost from the other table. It should automatically show the 123 as 000000000000123 in the CostTxt field.

However, this will only show it as such and not save it including the zeros.

If you would like to save it as such, then you might wanna do it through VBA on a form using the Format property. Costxt is a string I presume from its name.
Aug 19 '08 #2

puppydogbuddy
Expert 100+
P: 1,923
I have a table with 2 fields (Cost) and (CostTxt).
I need to update (CostTxt) with the value of (Cost), where (Cost) is 123 and (CostTxt) becames 000000000000123.
The size of field (CostTxt) is 15.
If these fields are on a bound form, then in the form:
try putting this in the format property of CostTxt: "000000000000000"

and this in the control source property of CostTxt: = Forms!YourForm!Cost
Aug 19 '08 #3

100+
P: 167
Expand|Select|Wrap|Line Numbers
  1. Private Sub Cost_AfterUpdate()
  2. If Len(Me!Cost) > 0 And Len(Me!Cost) < 16 Then
  3. Me!CostTxt = Left("000000000000000", 15 - Len(Me!Cost)) & Me!Cost
  4. Else
  5. MsgBox "Cost is not entered or is larger than 15 charachters"
  6. End If
  7. End Sub
Aug 19 '08 #4

Post your reply

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