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!

Removing 0 (Command Parameters)

Status
Not open for further replies.

sdempsey

Programmer
Mar 23, 2005
36
GB
I have 6 digit varchar's stored in a table such as 030405, these are always 6 characters.

I have created a form and a combo list box. In the combo list box a person 6 digit number is displyed along with their name. New_Person has a data type of String

Code

New_Person = [Forms]![New_Person]![New_Number]
Set param1 = cmd.CreateParameter("", adnChar, adParamReturnValue, 100)
cmd.Parameters.Append param1
param1.value = New_Person

The value of New_Person is not always 6 characters (it is in the table), it seems to remove any leading 0's. I need these to remain. I have tried a few different data types but not with much use.

Any ideas?

Thanks in advance.
 
Perhaps this ?
New_Person = Format([Forms]![New_Person]![New_Number], "000000")

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Or

New_Person = Right("000000" & [Forms]![New_Person]![New_Number], 6)
 
Hi,

Thanks for those ideas. I have tried them but with no success.

i have printed out the value of

[Forms]![New_Person]![New_Number]

and this is 6 characters it is only when it goes to the param object that the 0's are removed.is one of the settings wrong?

Thanks
 
I guess the culprit is here:
adnChar

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
BTW, just a hint:
Option Explicit

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top