Assistance with Decimal places in VBA script

PatrickWW

Board Regular
Joined
Jun 7, 2013
Messages
135
HTML:
Private Sub Command0_Click()
Dim MyDB As DAO.Database
Dim MyRS As DAO.Recordset
Dim strSQL As String
Dim strRptName As String
Dim count As Integer
strRptName = "PT Exports"
strSQL = "Select [IDCode] From CorePData;"
Set MyDB = CurrentDb
Set MyRS = MyDB.OpenRecordset(strSQL, dbOpenForwardOnly)
    With MyRS
    
        Do While Not MyRS.EOF
        DoCmd.OpenReport strRptName, acViewPreview, , "[ProductCode]='" & ![ProductCode] & "'"
        DoCmd.OutputTo acOutputReport, strRptName, acFormatRTF, "C:\Users\userid\my documents\PT\Reports\" & ![ProductCode] & "_NDXPublicationAttributes.doc"
        DoCmd.Close acReport, strRptName, acSaveNo
        .MoveNext
        Loop
    
    End With

MyRS.Close
Set MyRS = Nothing
End Sub
I am generating an SQL report which has a ton of trailing zero's and I was wondering if there was a way to eliminate those at the presentation layer. I read it's a big no-no to do that at the Database level (SQL) Any assistance would be greatly appreciated. This code copies the table and coverts each record into an RTF document. I am not against this going into an CSV or XLSX file, but the big piece is getting the leading zero's to slim down to 4 decimal places to the right. (.0000) no more than that. FYI this is in Access 2010
 
X I just went ahead and decided to do this all in Excel. I created a template sheet2 and did a copy into the template. I'm working through some pieces still but the copy piece is complete. Thanks again for the good ideas. Half the battle is making sure you use the right tool / solution.
 
Upvote 0

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.

Forum statistics

Threads
1,214,968
Messages
6,122,509
Members
449,089
Latest member
RandomExceller01

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top