Private Sub btn_addc_Click()
On Error Resume Next
If Me.txtAddc.Text = "" Then
MsgBox "Please fill up", vbInformation, "ADD CATEGORY"
Exit Sub
End If
If Me.btn_addc.Caption = "ADD" Then
If rs.State = adStateOpen Then rs.Close
rs.Open " Select * From tbl_category WHERE CategoryList ", db, adOpenStatic, adLockOptimistic
If rs.RecordCount > 0 Then
MsgBox "The Category you have entered is already Existed", vbCritical, "Error"
btn_refresh_Click
Me.txtAddc.Text = ""
Me.txtAddc.SetFocus
Else
With rs
.AddNew
.Fields("CategoryList") = Me.cmb_addc.Text
.Update
End With
MsgBox " Category Successfully Added.", vbInformation, "CATEGORY"
btn_refresh_Click
End If
End If
End Sub
Kemuel
0
Newbie Poster
Recommended Answers
Jump to PostWhy do you assume that if RecordCount is greater than zero the record already exists?
Do you not allow to update existing records?
Your indentation is bad, Very bad. Very bad. (Paraphrasing an Amrican...)
Assuming you are using Visual Studio, set breakpoints and dive into a wonderful debugger to watch …
Jump to PostThis type of post is getting to be standard on this site. If there is a point to it, we're left to guess what that point is. It's annoying. I see it tagged with "Visual Basic 6", which I know next to nothing about EXCEPT that Microsoft told everyone not …
All 7 Replies
ddanbe
2,724
Professional Procrastinator
Featured Poster
rproffitt
commented:
Armenian is better on this. Շատ վատ. Shat vat!
+14
AssertNull
1,094
Practically a Posting Shark
rproffitt
commented:
A thesis based on something from 1998. Must be an archaeology student.
+14
ddanbe
2,724
Professional Procrastinator
Featured Poster
rproffitt
2,565
"Nothing to see here."
Moderator
AssertNull
1,094
Practically a Posting Shark
ddanbe
2,724
Professional Procrastinator
Featured Poster
AssertNull
1,094
Practically a Posting Shark
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.