Format Number Long Integer Field

Table1 is Source Table and Field5 is Number Long Integer In Table1.
The First Query(Append)(Qry1_Update_6Chars) Formats Field5 find, if Field5 = 6 Characters:  
 ADD-TIME: CStr(Format(CDate(Left([Field5],2) & ":" & Mid([Field5],3,2)),"hh:nn AM/PM"))
---------------------------------------------------------------------------------------------------------------
My problem is Qry2_Update_5Chars which I tried append query:
ADD-TIME: IIf(Len([Field5])=5,CStr(Format(CDate(Left([Field5],1) & ":" & Mid([Field5],2,2)),"hh:nn AM/PM")))
If you just view it, it seems find but if try to Run to Append it, it doesn’t work.
Any suggestions would be appreciated!
---------------------------------------------------------------------------------------------------------------
Table2 now show QRy1_Update_6Chars  completed, If I can just get is Qry2_Update_5Chars to work.
Foramt.mdb
ca1358Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

FlysterCommented:
If you are trying to get the time value in table 2 to match field 5 in table 1, you need to create a relationship between the 2. Also, you should use an Update query, not an Append. Here's the sql:
UPDATE Table1 INNER JOIN Table2 ON Table1.Field1 = Table2.[COMMITMENT-NUM] SET Table2.[ADD-Time] = IIf(Len([Field5])=5,CStr(Format(CDate(Left([Field5],1) & ":" & Mid([Field5],2,2)),"hh:nn AM/PM")));

Open in new window

See attached
Flyster
Format.mdb
0
ca1358Author Commented:
Qry2_Update_5chars does update the 5 Characters but wipes out 6 Characters in the Add_Time Field.

Dont understand why.
0
Gustav BrockCIOCommented:
First, you should never store date or time as anything else than data type Date. No exceptions.

Second, you only need one query:

INSERT INTO
    Table2
    ( [COMMITMENT-NUM], [ADD-TIME] )
SELECT
    Table1.Field1,
    TimeValue(Format("0" & [Field5],"!@@\:@@\:@@")) AS TrueTime
FROM
    Table1;

If you insist on a text date, apply Format:

INSERT INTO
    Table2
    ( [COMMITMENT-NUM], [ADD-TIME] )
SELECT
    Table1.Field1,
    Format(TimeValue(Format("0" & [Field5],"!@@\:@@\:@@")), "hh:nn AM/PM") AS TextTime
FROM
    Table1;

/gustav
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ca1358Author Commented:
Thank you both for your help.  Sorry but I am not in control of the Extracts and I agree with you they should of format as Time data type.  I thank you again for helping learning more about Formatting.
0
Gustav BrockCIOCommented:
You are welcome!

/gustav
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.