Results 1 to 15 of 15

Thread: Type Mismatch

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Fremont Ohio 43420
    Posts
    253

    Exclamation

    I keep getting this type mismatch error when I go to update on one of my forms. I have looked up every possible cause in the Help file, but there is nothing explaining my problem or helping with a solution. I also have an error handling trap, but it just comes up with error '-2147352571 Typemismatch. Does anyone have any ideas what could be wrong?

    Thanks Aja

  2. #2
    Guest
    On what line do you get the error?

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Fremont Ohio 43420
    Posts
    253
    It doesn't take me to any line, the error box only has an ok button on it.

  4. #4
    Guest
    After you click OK it should highlight the line with the error for you.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Fremont Ohio 43420
    Posts
    253
    I know, but it doesn't do that. The error handling code I use looks like this:

    private sub
    error goto errorupdate
    'code
    exitupdate:
    exit sub
    errorupdate:
    msgbox err.number & vbcrlf & err.description, , "error"
    resume exitupdate
    end sub

    Does this error handling look right?

  6. #6
    Addicted Member
    Join Date
    Jul 1999
    Location
    St-Élie d'Orford, Quebec, Canada
    Posts
    133
    Are you using controls that are "Binded" to fields in a table...
    If so, it's one of control's datafield that is not spelled right... or data is of different type...

    [Edited by *Vince on 09-27-2000 at 11:58 AM]

  7. #7
    Guest
    Could you please post this procedure?

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Fremont Ohio 43420
    Posts
    253
    Private Sub cmdUpdate_Click()
    Dim stroldMachineno As String
    Dim stroldOperName As String
    Dim stroldStartTime As String
    Dim stroldEndTime As String
    Dim stroldRepairTime As String
    Dim stroldSetupTime As String
    Dim stroldPMTime As String
    Dim stroldPartsDesc As String
    Dim stroldComments As String
    Dim strMessage As String
    Dim strSql As String
    Dim fldNo As Field
    Dim fldName As Field
    Dim fldStart As Field
    Dim fldEnd As Field
    Dim fldRTime As Field
    Dim fldSTime As Field
    Dim fldPTime As Field
    Dim fldParts As Field
    Dim fldComments As Field

    On Error GoTo ErrorUpdate

    strSql = "Select Machineno, OperName, StartTime, EndTime, RepairTime, SetupTime, PMTime, PartsDesc, Comments From MachineMaintenance"

    Set rsMachineMaintenance = New ADODB.Recordset

    With rsMachineMaintenance
    .Open strSql, cnn, adOpenDynamic, adLockOptimistic

    Set fldNo = .Fields("Machineno")
    Set fldName = .Fields("OperName")
    Set fldStart = .Fields("StartTime")
    Set fldEnd = .Fields("EndTime")
    Set fldRTime = .Fields("RepairTime")
    Set fldSTime = .Fields("StartTime")
    Set fldPTime = .Fields("PMTime")
    Set fldParts = .Fields("PartsDesc")
    Set fldComments = .Fields("Comments")

    stroldMachineno = fldNo
    stroldOperName = fldName
    stroldStartTime = fldStart
    stroldEndTime = fldEnd
    stroldRepairTime = fldRTime
    stroldSetupTime = fldSTime
    stroldPMTime = fldPTime
    stroldPartsDesc = fldParts
    stroldComments = fldComments

    fldNo = txtMachineno
    fldName = txtOperName
    fldStart = txtStartTime
    fldEnd = txtEndTime
    fldRTime = txtRepairTime
    fldSTime = txtSetupTime
    fldPTime = txtPMTime
    fldParts = txtPartsDesc
    fldComments = txtComments

    strMessage = "Edit in progress:" & vbCrLf & _
    "Original data = " & _
    stroldMachineno & " " & stroldOperName & " " & stroldStartTime & " " & stroldEndTime & " " & _
    stroldRepairTime & " " & stroldSetupTime & " " & stroldPMTime & " " & stroldPartsDesc & " " & _
    stroldComments & _
    "Data in buffer = " & _
    fldNo & " " & fldName & " " & fldRTime & " " & fldSTime & " " & _
    fldPTime & " " & fldParts & " " & fldComments & vbCrLf & vbCrLf & _
    "Use Update to replace the original data with " & _
    "the buffered data in the Recordset?"

    If MsgBox(strMessage, vbYesNo) = vbYes Then
    .Update
    Else
    .CancelUpdate
    End If

    MsgBox "Data in recordset = " & fldNo & " " & fldName & " " & fldStart & " " & fldEnd & " " & _
    fldRTime & " " & fldSTime & " " & fldPTime & " " & fldParts & " " & fldComments

    If Not (stroldMachineno = fldNo And stroldOperName = fldName And stroldStartTime = fldStart And _
    stroldEndTime = fldEnd And stroldRepairTime = fldRTime And stroldSetupTime = fldSTime And _
    stroldPMTime = fldPTime And stroldPartsDesc = fldParts And stroldComments = fldComments) Then
    fldNo = stroldMachineno
    fldName = stroldOperName
    fldStart = stroldStartTime
    fldEnd = stroldEndTime
    fldRTime = stroldRepairTime
    fldSTime = stroldSetupTime
    fldPTime = stroldPMTime
    fldParts = stroldPartsDesc
    fldComments = stroldComments
    .Update
    End If

    .Close
    End With

    cnn.Close

    ExitUpdate:
    Exit Sub

    ErrorUpdate:
    MsgBox Err.Number & vbCrLf & Err.Description, , "Error"
    Resume ExitUpdate
    End Sub

  9. #9
    Guest
    Ok... I thought the procedure was smaller.
    Anyway, remove the On Error line for a moment, run the program, and check in what line the error occurs.

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Fremont Ohio 43420
    Posts
    253
    The error is on line

    fldSTime = txtSetupTime

    Sorry about all the code!!!

  11. #11
    Guest
    What type is the field fldSType?

  12. #12

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Fremont Ohio 43420
    Posts
    253
    fldSTime is dimmed as a field.
    txtSetupTime is a integer.

  13. #13
    Guest
    I meant, is the field a text field? A date field? Autonumber?

  14. #14

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Fremont Ohio 43420
    Posts
    253

    Red face

    I figured out the problem. The line the error goes to is wrong because I should of had "SetupTime" instead of "StartTime". I'm sorry about all the headaches I probably gave you, but I appreciated you trying to help me out ScOrp!!

    Thanks again, Aja

  15. #15
    Guest
    No problem.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width