Hello
I am getting an type Mistmach error every time I try adding a new record by calling a function. I am really clueless
THe code break on the calling function with all the parameters.
If ADD_ROLLNUMBER_RECORD( _
txtRollNumber.Text, _
txtRollDescription.Text, _
txtDrawingNumber.Text, _
txtCoverTopStockThick.Text, _
txtCoverThickness.Text, _
txtInitialCost.Text, _
txtRollFaceLenght.Text, _
txtRollOveralLength.Text, _
txtRollBearingCenterToCenterLenght.Text, _
txtRollWeight.Text, _
txtRollShellOD.Text, _
txtRollCoverMaxOD.Text, _
txtRollCoverMinOD.Text, _
txtRollBearingNumber.Text, _
txtRollBearingApaptNumber.Text, _
txtMaxSpeed.Text, _
txtRollCoverHardness.Text, _
txtHardnessTolerance.Text, _
txtSurfaceFinishTolerance.Text, txtMemo.Text) = True Then
Record Added successfully, else there was an error.
Here is the Function that adds new records to database
Private Function ADD_ROLLNUMBER_RECORD(ByVal RollNumber As String, _
ByVal RollDescription As String, _
ByVal DrawingNumber As String, _
ByVal CoverTopStockThick As String, _
ByVal CoverThickness As String, _
ByVal InitialCost As Currency, _
ByVal RollFaceLength As String, _
ByVal RollOveralLength As String, _
ByVal RollBearingCenterToCenterLenght As String, _
ByVal RollWeight As String, _
ByVal RollShellOD As String, _
ByVal RollCoverMaxOD As String, _
ByVal RollCoverMinOD As String, _
ByVal RollBearingNumber As String, _
ByVal RollBearingApaptNumber As String, _
ByVal MaxSpeed As String, _
ByVal RollCoverHardness As String, _
ByVal HardnessTolerance As String, _
ByVal SurfaceFinishTolerance As String, _
ByVal strMemo As String) As Boolean
Dim tmpSQL As String
On Error GoTo ADD_RECORD_ERROR
tmpSQL = ""
tmpSQL = "Select * from tblRollSpecification"
Set moRS = New ADODB.Recordset
moRS.Open tmpSQL, goConn, adOpenKeyset, adLockOptimistic
moRS.AddNew
'RollNumbe
moRS.Fields("RollNumber") = Trim$(txtRollNumber)
'Description
moRS.Fields("txtRollDescription") = Trim$(txtRollDescription)
moRS.Fields("cboMachinePrimary") = cboMachinePrimary.ItemData(cboMachinePrimary.ListIndex)
moRS.Fields("cboRollType") = cboRollType.ItemData(cboRollType.ListIndex)
moRS.Fields("txtDrawingNumber") = Trim$(txtDrawingNumber)
moRS.Fields("cboRollManufacturer") = cboRollManufacturer.ItemData(cboRollManufacturer.ListIndex)
moRS.Fields("cboPhysicalLocation") = cboPhysicalLocation.ItemData(cboPhysicalLocation.ListIndex)
moRS.Fields("txtCoverTopStockThick") = Trim$(txtCoverTopStockThick)
moRS.Fields("txtCoverThickness") = Trim$(txtCoverThickness)
moRS.Fields("txtInitialCost") = Trim$(txtInitialCost)
moRS.Fields("txtRollFaceLenght") = Trim$(txtRollFaceLenght)
moRS.Fields("txtRollOveralLength") = Trim$(txtRollOveralLength)
moRS.Fields("txtRollBearingCenterToCenterLenght") = Trim$(txtRollBearingCenterToCenterLenght)
moRS.Fields("txtRollWeight") = Trim$(txtRollWeight)
moRS.Fields("txtRollShellOD") = Trim$(txtRollShellOD)
moRS.Fields("txtRollCoverMaxOD") = Trim$(txtRollCoverMaxOD)
moRS.Fields("txtRollCoverMinOD") = Trim$(txtRollCoverMinOD)
moRS.Fields("txtRollBearingNumber") = Trim$(txtRollBearingNumber)
moRS.Fields("txtRollBearingApaptNumber") = Trim$(txtRollBearingApaptNumber)
moRS.Fields("txtMaxSpeed") = Trim$(txtMaxSpeed)
moRS.Fields("cboRollCoverMaterialID") = cboRollCoverMaterialID.ItemData(cboRollCoverMaterialID.ListIndex)
moRS.Fields("txtRollCoverHardness") = Trim$(txtRollCoverHardness)
moRS.Fields("txtHardnessTolerance") = Trim$(txtHardnessTolerance)
moRS.Fields("txtSurfaceFinishTolerance") = Trim$(txtSurfaceFinishTolerance)
moRS.Fields("txtMemo") = Trim$(txtMemo)
'Update Database
moRS.Update
DoEvents
ADD_RECORD = True
Debug.Print "frmRollSpec.ADD_RECORD - Record Added"
Exit Function
ADD_RECORD_ERROR:
If err.Number <> 0 Then
MsgBox "ERROR : frmRollSpec.ADD_RECORD" & vbNewLine & _
"ERROR # " & Str$(err.Number) & _
"DESCRIPTION - " & err.Description & vbNewLine, vbCritical + vbOKOnly
err.Clear
ADD_RECORD = False
End If
End Function
I will appreciate any help
Thank you
ParyGoal
I am getting an type Mistmach error every time I try adding a new record by calling a function. I am really clueless
THe code break on the calling function with all the parameters.
If ADD_ROLLNUMBER_RECORD( _
txtRollNumber.Text, _
txtRollDescription.Text, _
txtDrawingNumber.Text, _
txtCoverTopStockThick.Text, _
txtCoverThickness.Text, _
txtInitialCost.Text, _
txtRollFaceLenght.Text, _
txtRollOveralLength.Text, _
txtRollBearingCenterToCenterLenght.Text, _
txtRollWeight.Text, _
txtRollShellOD.Text, _
txtRollCoverMaxOD.Text, _
txtRollCoverMinOD.Text, _
txtRollBearingNumber.Text, _
txtRollBearingApaptNumber.Text, _
txtMaxSpeed.Text, _
txtRollCoverHardness.Text, _
txtHardnessTolerance.Text, _
txtSurfaceFinishTolerance.Text, txtMemo.Text) = True Then
Record Added successfully, else there was an error.
Here is the Function that adds new records to database
Private Function ADD_ROLLNUMBER_RECORD(ByVal RollNumber As String, _
ByVal RollDescription As String, _
ByVal DrawingNumber As String, _
ByVal CoverTopStockThick As String, _
ByVal CoverThickness As String, _
ByVal InitialCost As Currency, _
ByVal RollFaceLength As String, _
ByVal RollOveralLength As String, _
ByVal RollBearingCenterToCenterLenght As String, _
ByVal RollWeight As String, _
ByVal RollShellOD As String, _
ByVal RollCoverMaxOD As String, _
ByVal RollCoverMinOD As String, _
ByVal RollBearingNumber As String, _
ByVal RollBearingApaptNumber As String, _
ByVal MaxSpeed As String, _
ByVal RollCoverHardness As String, _
ByVal HardnessTolerance As String, _
ByVal SurfaceFinishTolerance As String, _
ByVal strMemo As String) As Boolean
Dim tmpSQL As String
On Error GoTo ADD_RECORD_ERROR
tmpSQL = ""
tmpSQL = "Select * from tblRollSpecification"
Set moRS = New ADODB.Recordset
moRS.Open tmpSQL, goConn, adOpenKeyset, adLockOptimistic
moRS.AddNew
'RollNumbe
moRS.Fields("RollNumber") = Trim$(txtRollNumber)
'Description
moRS.Fields("txtRollDescription") = Trim$(txtRollDescription)
moRS.Fields("cboMachinePrimary") = cboMachinePrimary.ItemData(cboMachinePrimary.ListIndex)
moRS.Fields("cboRollType") = cboRollType.ItemData(cboRollType.ListIndex)
moRS.Fields("txtDrawingNumber") = Trim$(txtDrawingNumber)
moRS.Fields("cboRollManufacturer") = cboRollManufacturer.ItemData(cboRollManufacturer.ListIndex)
moRS.Fields("cboPhysicalLocation") = cboPhysicalLocation.ItemData(cboPhysicalLocation.ListIndex)
moRS.Fields("txtCoverTopStockThick") = Trim$(txtCoverTopStockThick)
moRS.Fields("txtCoverThickness") = Trim$(txtCoverThickness)
moRS.Fields("txtInitialCost") = Trim$(txtInitialCost)
moRS.Fields("txtRollFaceLenght") = Trim$(txtRollFaceLenght)
moRS.Fields("txtRollOveralLength") = Trim$(txtRollOveralLength)
moRS.Fields("txtRollBearingCenterToCenterLenght") = Trim$(txtRollBearingCenterToCenterLenght)
moRS.Fields("txtRollWeight") = Trim$(txtRollWeight)
moRS.Fields("txtRollShellOD") = Trim$(txtRollShellOD)
moRS.Fields("txtRollCoverMaxOD") = Trim$(txtRollCoverMaxOD)
moRS.Fields("txtRollCoverMinOD") = Trim$(txtRollCoverMinOD)
moRS.Fields("txtRollBearingNumber") = Trim$(txtRollBearingNumber)
moRS.Fields("txtRollBearingApaptNumber") = Trim$(txtRollBearingApaptNumber)
moRS.Fields("txtMaxSpeed") = Trim$(txtMaxSpeed)
moRS.Fields("cboRollCoverMaterialID") = cboRollCoverMaterialID.ItemData(cboRollCoverMaterialID.ListIndex)
moRS.Fields("txtRollCoverHardness") = Trim$(txtRollCoverHardness)
moRS.Fields("txtHardnessTolerance") = Trim$(txtHardnessTolerance)
moRS.Fields("txtSurfaceFinishTolerance") = Trim$(txtSurfaceFinishTolerance)
moRS.Fields("txtMemo") = Trim$(txtMemo)
'Update Database
moRS.Update
DoEvents
ADD_RECORD = True
Debug.Print "frmRollSpec.ADD_RECORD - Record Added"
Exit Function
ADD_RECORD_ERROR:
If err.Number <> 0 Then
MsgBox "ERROR : frmRollSpec.ADD_RECORD" & vbNewLine & _
"ERROR # " & Str$(err.Number) & _
"DESCRIPTION - " & err.Description & vbNewLine, vbCritical + vbOKOnly
err.Clear
ADD_RECORD = False
End If
End Function
I will appreciate any help
Thank you
ParyGoal