Heenan, Lambert
Lambert.Heenan at chartisinsurance.com
Thu Aug 26 14:59:28 CDT 2010
Steve,
Are you sure about the data type of the table field? I just ran this code...
Dim dbs As DAO.Database
Dim rstNewJobNo As DAO.Recordset
Dim Job As String
Set dbs = CurrentDb
Job = txtNewJobNo
Set rstNewJobNo = dbs.OpenRecordset("NewJobNo")
With rstNewJobNo
.AddNew
!txtJobNum = Job
!LongJobNo = Job
!DoubleJobNo = Job
.Update
.Close
End With
Set rstNewJobNo = Nothing
DoCmd.OpenTable "NewJobNo"
(Note your code uses .Edit with no find method, so it gives a "no current record" error )
The table I am using has three fields: txtJobNum defined as Text, LongJobNo which is a Long and DoubleJobNo which is a Double.
When I run the code I get the following results in the table...
txtJobNum : 10.40
LongJobNo : 10
DoubleJobNo : 10.4
So it looks like your filed might be a double or single FP value.
Lambert
-----Original Message-----
From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Steve Turner
Sent: Thursday, August 26, 2010 3:40 PM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Droping trailing zero
Lambert, here is what I pasted in to make a report print button for new jobs. The txtNewJob is the textbox I set up to get the number on the form. If I use a number not ending in zero it works.
Private Sub btnPrNewJob_Click()
Dim rstNewJobNo As Recordset
Dim strError As String
Dim dbs As Database
Dim qdf As QueryDef
Dim rst As Recordset
Dim db As Database
Dim Job As String
Set dbs = CurrentDb
Job = txtNewJob
Set rstNewJobNo = dbs.OpenRecordset("NewJobNo")
With rstNewJobNo
.Edit
!LongJobNum = Job
.Update
End With
Dim strDocName As String
strDocName = "rptProjectNumberAssignmentSheet"
On Error GoTo Err_btnPrNewJob_Click
DoCmd.OpenReport strDocName, acViewPreview
Exit_btnPrNewJob_Click:
Exit Sub
Err_btnPrNewJob_Click:
If Err = ConErrRptCanceled Then
Resume Exit_btnPrNewJob_Click
Else
MsgBox Err.Description
Resume Exit_btnPrNewJob_Click
End If
End Sub
Steve A. Turner
Controller
Mid-South Engineering Co. Inc
E-Mail: sturner at mseco.com and saturner at mseco.com
<snip>