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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how can i format fields in select statement

Status
Not open for further replies.

andypower

Programmer
Aug 10, 2004
23
0
0
IN
hello myself avi developing application in vb and access
i want to fomrat the fields in select statement i.e i want to control digits after decimal pt. in select statement.
plwase read following e.g. carefully and help me.
i have Salesvoucher Table in my database in which there is one field 'NetWeight'. its datatype is Double. while inserting values in this table i m not formating data[this happened by mistake and i recognised it when i face problem]now when i m displaying data i want to format NetWeight.below is my query

StrSQL = ""
StrSQL = "Select Material_Name,NetWeight From Salesvoucher where materialname='Chain'
RsMaterial.Open StrSQL, Conn, adOpenKeyset
GetBillMaterial = RsMaterial.GetString(adClipString, -1, "-", " ", "(NULL)")

here i m using getstring not any loop. if i use Round then it gives me Error. so plz help me reg. this
 
there are 2 ways of doing it

1st in vb - just format the output with the format command
i.e. myValue = format(RsMaterial!NetWeight ,"0.00")

2nd Do it in the SQL
Note this will not work with sql but access is ok


Select Material_Name,format(NetWeight,"0.00") From Salesvoucher where materialname='Chain'

if it is a big number then you could do somthing like this

Format(5459.4, "##,##0.00") ' Returns "5,459.40".
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top