PDA

View Full Version : Facing Run-time error-13 "Type Mismatch" while edit and update user



bala04msw
07-29-2018, 11:08 PM
Dear Experts,


Kindly help me to resolve this issue.


I have developed user form for data entry purposes and its works fine with store data in excel worksheet. Now, i have added the edit option to update the data, if any changes. Here i am facing two issues and as follows:


1. In the edit code: There is a field called Time in and Time out, While i retrieve the data, time is coming as "0.25" instead of "06.00"
2. After edit the user form, i want to update the corrected data in the same row of the excel worksheet. But i am facing Run-time error '13' Type mismatch


Data is retrieved to edit based on Report Number: "2907201845PU" (Example)




I have used the following code for edit:

Private Sub btnSVedit_Click()
Dim r As Variant
With Sheets("SVReport")
r = Application.Match(txtsearchreportno, .Range("A:A"), 0)
If IsError(r) Then
MsgBox txtsearchreportno, vbExclamation, "No Match Found"
Else
cbtown.Text = .Range("B" & r).Value
cbdistrict.Text = .Range("C" & r).Value
cbstate.Text = .Range("D" & r).Value
cbfacilityname.Text = .Range("E" & r).Value
txttypeofsite.Text = .Range("F" & r).Value
txttypeoffacility.Text = .Range("G" & r).Value
txtsvetanasiteid.Text = .Range("H" & r).Value
txtsimsid.Text = .Range("I" & r).Value
txthivpulseid.Text = .Range("J" & r).Value
txtdate.Text = .Range("K" & r).Value
txtreportno.Text = .Range("A" & r).Value
txttimein.Text = .Range("L" & r).Value
txttimeout.Text = .Range("M" & r).Value
cbsvdonebyname.Text = .Range("N" & r).Value
cbsvdonebydesignation.Text = .Range("O" & r).Value
txtsvothers.Text = .Range("P" & r).Value
obdoctor.Value = .Range("W" & r).Value
'etc.
End If
End With
End Sub




I have used the following code for update:



Private Sub btnupdate_Click()
If Me.txtsearchreportno.Value = "" Then
MsgBox "Report No. Can Not be Blank!!!", vbExclamation, "Report No"
Exit Sub
End If
ReportNo = Me.txtsearchreportno.Value
Sheets("SVReport").Select
Dim rowselect As Long
Dim msg As String
Dim ans As String
rowselect = Me.txtsearchreportno.Value
rowselect = rowselect + 1
Rows(rowselect).Select
Cells(rowselect, 2) = Me.cbtown.Value
Cells(rowselect, 3) = Me.cbdistrict.Value
Cells(rowselect, 4) = Me.cbstate.Value
Cells(rowselect, 5) = Me.cbfacilityname.Value
Cells(rowselect, 6) = Me.txttypeofsite.Value
Cells(rowselect, 7) = Me.txttypeoffacility.Value
Cells(rowselect, 8) = Me.txtsvetanasiteid.Value
Cells(rowselect, 9) = Me.txtsimsid.Value
Cells(rowselect, 10) = Me.txthivpulseid.Value
Cells(rowselect, 11) = Me.txtdate.Value
Cells(rowselect, 12) = Me.txtreportno.Value
Cells(rowselect, 13) = Me.txttimein.Value
Cells(rowselect, 14) = Me.txttimeout.Value
Cells(rowselect, 15) = Me.cbsvdonebyname.Value
Cells(rowselect, 16) = Me.cbsvdonebydesignation.Value
Cells(rowselect, 17) = Me.txtsvothers.Value
Cells(rowselect, 23) = Me.obdoctor.Value
rowselect = rowselect - 1
msg = "Sl No " & rowselect & " Successfully Updated...Continue?"
Unload Me
ans = MsgBox(msg, vbYesNo, "Update")
If ans = vbYes Then
SVeditForm.Show
Else
Sheets("SVReport").Select
End If
End Sub




Kindly do the needful


Regards

p45cal
07-30-2018, 02:43 AM
cross posted elsewhere

bala04msw
07-30-2018, 02:57 AM
cross posted elsewhere

But i have quoted the vbaexpress reference link. Kindly do the needful.

Regards

p45cal
07-30-2018, 03:56 AM
You need to link to the other site(s) here.