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

TYPE MISMATCHES USING ACCESS 2000 DATABASE 1

Status
Not open for further replies.

TNN

Programmer
Sep 13, 2000
417
US
Not sure if this is the right forum to ask this but here goes.
Getting errors "TYPE MISMATCH" with following code:

With objSource.adoRsPyrlCalc4Ded
.AddNew
!EMPNO = strEmployee_Number
!DedNo = Me.txt1(Index - 4).Text
!DEPT = "1"
!AMOUNT = Me.txt1(Index).Text
!LIMIT = Me.txt1(Index - 1).Text
.Update
End With

In the Access 2000 database I have assigned datatype NUMBER to all fields. As you can see I am using text boxes to fill many of the database fields. When I have no numbers in the text box but a "" I get a type mismatch. How do I handle that situation?

I also have the same situation with text boxes bound as part of a binding collection. When I try to update the binding collection I get the same type mismatch error.

Any help is appreciated.

TNN, Tom
TNPAYROLL@AOL.COM



TOM
 

Use the Nz function to convert the empty (NULL) text boxes to 0.

!AMOUNT = Nz(Me.txt1(Index).Text,0) Terry L. Broadbent
FAQ183-874 contains tips for posting questions in these forums.
NOTE: Reference to the FAQ is not directed at any individual.
 
Hello All,
The following If, Else works but is awful cumbersome(lot of code):

With objSource.adoRsPyrlCalc4Ded
.AddNew
!EMPNO = strEmployee_Number
!DedNo = Me.txt1(Index - 4).Text
!DEPT = "1"
!AMOUNT = Me.txt1(Index).Text
If Me.txt1(Index - 1).Text = "" Then
!LIMIT = Null
Else
!LIMIT = Me.txt1(Index - 1).Text
End If
.Update
.MovePrevious
'MovePrevious needed to save record and MoveNext to make record current in order
'to Bkmrk per below.
.MoveNext
End With

TNN, Tom
TNPAYROLL@AOL.COM

TOM
 
Nz is a function in Access or VBA. Perhaps you need to check the references to see if any are missing.

Open any module.
Go to Tools, References.
See if any references are missing.
Unselect unneeded references.
Resolve missing references that are needed.

Also, see thread181-6094.

Check this web page for more info about missing references.

Terry L. Broadbent
FAQ183-874 contains tips for posting questions in these forums.
NOTE: Reference to the FAQ is not directed at any individual.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top