Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Importing / Linking / May 2007

Tip: Looking for answers? Try searching our database.

Numeric Data type

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Melody - 22 May 2007 18:44 GMT
Hello, I really need some help.  I have an Access 2003 form and a SQL 2000
table.  I have a stored procedure to insert records.  I keep getting a
"Precision is invalid" when I try to execute the stored procedure because I
changed some of my fields to "Numeric" from "Integer" because I need decimal
places.  Here is my info:

In Access module:
Public Function InsertTimeSheet(pDate, pStartTime, pLunchOut, pLunchIn,
pEndTime, pReasonOT, pVacationHours, pSickHours, pOtherHours, pUnpaidHours,
pEmployeeID, pHolidayHours)
Set cmd = New ADODB.Command
With cmd
 Set .ActiveConnection = CurrentProject.Connection
    .CommandText = "spTimeSheetInsert"
   .CommandType = adCmdStoredProc
   .CommandTimeout = 6000
   
   .Parameters.Append .CreateParameter("@StartDate", adDBDate,
adParamInput, 8, pDate)
   .Parameters.Append .CreateParameter("@StartTime", adDBDate,
adParamInput, 8, pStartTime)
   .Parameters.Append .CreateParameter("@LunchOut", adDBDate, adParamInput,
8, pLunchOut)
   .Parameters.Append .CreateParameter("@LunchIn", adDBDate, adParamInput,
8, pLunchIn)
   .Parameters.Append .CreateParameter("@EndTime", adDBDate, adParamInput,
8, pEndTime)
   .Parameters.Append .CreateParameter("@ReasonOT", adVarChar,
adParamInput, 20, pReasonOT)
   .Parameters.Append .CreateParameter("@VacationHours", adNumeric,
adParamInput, 9, pVacationHours)
   .Parameters.Append .CreateParameter("@SickHours", adNumeric,
adParamInput, 9, pSickHours)
   .Parameters.Append .CreateParameter("@OtherHours", adNumeric,
adParamInput, 9, pOtherHours)
   .Parameters.Append .CreateParameter("@UnpaidHours", adNumeric,
adParamInput, 9, pUnpaidHours)
   .Parameters.Append .CreateParameter("@EmployeeID", adInteger,
adParamInput, 0, pEmployeeID)
   .Parameters.Append .CreateParameter("@HolidayHours", adInteger,
adParamInput, 0, pHolidayHours)

   Set rst = .Execute
End With
Set cmd = Nothing
End Function

My stored procedure:
CREATE PROCEDURE [dbo].[spTimeSheetInsert]
    @StartDate datetime,
    @StartTime datetime,
    @LunchOut datetime,
    @LunchIn datetime,
    @EndTime datetime,
    @ReasonOT varchar(20),
    @VacationHours numeric,
    @SickHours numeric,
    @OtherHours numeric,
    @UnpaidHours numeric,
    @EmployeeID int,
    @HolidayHours int
AS
SET NOCOUNT ON
INSERT INTO [dbo].[tblTimeSheet] (
    [StartDate],
    [StartTime],
    [LunchOut],
    [LunchIn],
    [EndTime],
    [ReasonOT],
    [VacationHours],
    [SickHours],
    [OtherHours],
    [UnpaidHours],
    [EmployeeID],
    [HolidayHours]
) VALUES (
    @StartDate,
    @StartTime ,
    @LunchOut,
    @LunchIn,
    @EndTime,
    @ReasonOT,
    @VacationHours,
    @SickHours,
    @OtherHours,
    @UnpaidHours,
    @EmployeeID,
    @HolidayHours
)
GO

My table, the Vacation, Sick, Other and Unpaid Hours are all

Data Type:  Numeric
Length:  9
Allow Nulls:  True

Precision:  19
Scale:  4

I have changed these fields to decimal, double etc and keep getting the same
error.  I am so confused now I really just don't know what to use for my
field type.  The data I am storing in these fields numeric and may have up to
2 decimal places.  For example:

3.5
7
4.75

Any help would be very greatly appreciated.
Mary Chipman [MSFT] - 23 May 2007 15:01 GMT
you don't need the numeric data type if you only need two decimal
places of precision - use smallmoney instead. I didn't pore through
your code, but if you don't specify the exact same precision and scale
each time for decimal/numeric data, SQL Server considers each to be a
separate data type.

-mary

>Hello, I really need some help.  I have an Access 2003 form and a SQL 2000
>table.  I have a stored procedure to insert records.  I keep getting a
[quoted text clipped - 107 lines]
>
>Any help would be very greatly appreciated.
Melody - 23 May 2007 15:30 GMT
Hi MAry, Thank you so much for your response.  I changed the data types in my
table to smallmoney and I changed the datatype in my stored proecdure to
smallmoney as well.  But what do I put for the datatype when I send the
parameter?  There is no smallmoney type.  I left it as decimal and changed
the length to 4 but I am still getting that error.  Should I change it to
something else?  Thank you.  

> you don't need the numeric data type if you only need two decimal
> places of precision - use smallmoney instead. I didn't pore through
[quoted text clipped - 115 lines]
> >
> >Any help would be very greatly appreciated.
Mary Chipman [MSFT] - 31 May 2007 16:34 GMT
Currency should work.

-mary

>Hi MAry, Thank you so much for your response.  I changed the data types in my
>table to smallmoney and I changed the datatype in my stored proecdure to
[quoted text clipped - 122 lines]
>> >
>> >Any help would be very greatly appreciated.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.