Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

INSERT INTO ... VALUES Drops leading zero 1

Status
Not open for further replies.

wavesurf

Programmer
Sep 11, 2001
2
US
The leading zero is dropped during this append query

Table named Calc exists with Text fields: Serial and Julian.

The Code:

Dim strJulain as string
strJulian = Right(year(date), 1) & DatePart("y", date())
DoCmd.RunSQL "INSERT INTO Calc(Serial, Julian) VALUES(tboSerial, " & strJulian & ")"

I tried to insert a line before the DoCmd like
strJulain=Format(strJulain, "0000")
or
strJulian=CStr(strJulain)
without any luck.

Using a breakpoint and stepping through shows a value of "0100" for strJuliain but 100 is shown in the table for Julian. The Serial field retains leading zeros retrieved from a form's textbox.

Any ideas?

 
DoCmd.RunSQL "INSERT INTO Calc(Serial, Julian) VALUES(tboSerial, '" & strJulian & "')"
 
Of course. I must be left-brained today. Thanks for your help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top