Problems again: Runtime Error 13 Type Mismatch: bombing out on
z = CDate(Mid(Left(i, Len(i) - 1), 1 + InStr(i, "(")))
This was working the other day with the help of PHV... whats happened? I am clueless and can't seem to get this right.
Public Function fblnMakeTable_F_ProdSched() MakeTbl_F_Data_ProductionSchedule
Dim a, i, x, y, z, strProdSched As String
Set DB = CurrentDb
strSQL = "Select * from R_DeliveryStatus"
Set RS = DB.OpenRecordset(strSQL, dbOpenDynaset)
RS.MoveFirst
Do While Not RS.EOF
strProdSched = RS.[prodnschedule].Value
x = RS.[FirstOfProjectPOID].Value
If Not IsNull(strProdSched) Then
If Not (strProdSched Like "No New*") Then
If Not (strProdSched Like "Schedule*") Then
a = Split(Replace(strProdSched, " ", ""), ",")
'Debug.Print a
For Each i In a
y = Val(Left(i, InStr(i, "(") - 1))
Debug.Print x
z = CDate(Mid(Left(i, Len(i) - 1), 1 + InStr(i, "(")))
'''z = CDate(Mid(i, 1 + InStr(i, "("), 6))
Debug.Print x
'MsgBox "ProductionPOId=" & x & ", ProdQty=" & y & ", ProdDate=" & z
CurrentDb.Execute "Insert Into tblProdSched (FirstOfProjectPOID, ProdQty, ProdDate) VALUES (" & x & ", '" & y & "', '" & z & "');"
Next
End If
End If
End If
RS.MoveNext
Loop
RS.Close
End Function
Private Function MakeTbl_F_Data_ProductionSchedule()
On Error GoTo ErrorHandler
DoCmd.RunSQL "CREATE TABLE tblProdSched (FirstOfProjectPOID text(20), ProdQty LONG, ProdDate DateTime)"
CurrentDb.TableDefs.Refresh
ErrorHandler:
Select Case Err.Number
Case 3010
DoCmd.DeleteObject acTable, "tblProdSched"
Resume
'Case Else
'MsgBox Err.Number & " " & Err.Description
End Select
End Function
z = CDate(Mid(Left(i, Len(i) - 1), 1 + InStr(i, "(")))
This was working the other day with the help of PHV... whats happened? I am clueless and can't seem to get this right.
Public Function fblnMakeTable_F_ProdSched() MakeTbl_F_Data_ProductionSchedule
Dim a, i, x, y, z, strProdSched As String
Set DB = CurrentDb
strSQL = "Select * from R_DeliveryStatus"
Set RS = DB.OpenRecordset(strSQL, dbOpenDynaset)
RS.MoveFirst
Do While Not RS.EOF
strProdSched = RS.[prodnschedule].Value
x = RS.[FirstOfProjectPOID].Value
If Not IsNull(strProdSched) Then
If Not (strProdSched Like "No New*") Then
If Not (strProdSched Like "Schedule*") Then
a = Split(Replace(strProdSched, " ", ""), ",")
'Debug.Print a
For Each i In a
y = Val(Left(i, InStr(i, "(") - 1))
Debug.Print x
z = CDate(Mid(Left(i, Len(i) - 1), 1 + InStr(i, "(")))
'''z = CDate(Mid(i, 1 + InStr(i, "("), 6))
Debug.Print x
'MsgBox "ProductionPOId=" & x & ", ProdQty=" & y & ", ProdDate=" & z
CurrentDb.Execute "Insert Into tblProdSched (FirstOfProjectPOID, ProdQty, ProdDate) VALUES (" & x & ", '" & y & "', '" & z & "');"
Next
End If
End If
End If
RS.MoveNext
Loop
RS.Close
End Function
Private Function MakeTbl_F_Data_ProductionSchedule()
On Error GoTo ErrorHandler
DoCmd.RunSQL "CREATE TABLE tblProdSched (FirstOfProjectPOID text(20), ProdQty LONG, ProdDate DateTime)"
CurrentDb.TableDefs.Refresh
ErrorHandler:
Select Case Err.Number
Case 3010
DoCmd.DeleteObject acTable, "tblProdSched"
Resume
'Case Else
'MsgBox Err.Number & " " & Err.Description
End Select
End Function