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

Run time error '3421'

Status
Not open for further replies.

kkgusta

MIS
Nov 10, 2005
42
NZ
Hi there the problem.
I am try to add a new data to the "actions" table with the following code. However I kept on getting error message when some of the ID field is null. I hope someone here can help me to solve the problem.

The error i got is Run time error '3421'
Data Type conversion error


Here is my code.......

Dim rs As Recordset
Dim testdate As Date
Dim StrTester, strComments As String
Dim IntResult, IntBuild, RowCount, RowCounter As Integer


'get result and assign them to the Variables
testdate = "" & [txtResult_Date]
StrTester = "" & [CboResult_Tester]
IntBuild = "" & [CboBuild]
IntResult = "" & [CboPassFail]
strComments = "" & [txtComments]


RowCount = Me.ListBulkResult.ListCount

Set rs = CurrentDb.OpenRecordset("Select * from actions")
For RowCounter = 0 To RowCount - 1

rs.AddNew
rs.Fields("Projectid") = Me.ListBulkResult.Column(0, RowCounter)
rs.Fields("scriptid") = Me.ListBulkResult.Column(2, RowCounter)
rs.Fields("Buildid") = "" & IntBuild
rs.Fields("Tested_Date") = "" & testdate
rs.Fields("testerid") = "" & StrTester
rs.Fields("result") = "" & IntResult
rs.Fields("Comments") = "" & strComments
rs.Fields("test_data") = ""
rs.Fields("Fault_No") = ""

rs.Update


Next RowCounter

rs.Close
 
And which line is highlighted when in debug mode ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
rs.Fields("Fault_No") = ""
looks like an assignment of a number to an empty string.
 
I keep getting Data Type Conversion Error 3421 on the following. Debug stops on !TimeInI = Me.TimeInI.Value.
Also, I don't get the error when I open the database and save the first record. It happens only when I try to save the second record.



Set db = CurrentDb
Set rst = db.OpenRecordset("Data")
With rst
.AddNew
!StudentFullName = Me.StudentFullName
!Staff1 = Me.Staff1
!Staff2 = Me.Staff2
!Staff3 = Me.Staff3
!Staff4 = Me.Staff4
!Staff5 = Me.Staff5
!cDate = Me.cDate
!Reason1 = Me.Reason1
!Reason2 = Me.Reason2
!Type1 = Me.Type1
!Type2 = Me.Type2
!Type3 = Me.Type3
!TimeInI = Me.TimeInI.Value
!TimeOutI = Me.TimeOutI.Value
!TimeInR = Me.TimeInR.Value
!TimeOutR = Me.TimeOutR.Value
!Room = Me.Room
!Door = Me.Door.Value
!ConstantContact = Me.ConstantContact.Value
!Checks = Me.Checks
.Update

End With

rst.Close

Dim ctl As Control
For Each ctl In Me.Controls
If ctl.Tag = "CLEARME" Then ctl.Value = ""
Next ctl
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top