hello...


Can you help me please, how can i use the checkbox if i want to display on my listiew

Active or not Active After clicking the addbutton.

Example


Jemz Gimz 123 then i will check the checkbox and click the Add button

it should display on my listview

Jemz Gimz 123 Active.

Can you help me please how can i do this.it this possible in checkbox?

Thank you in advance and I am hoping for your positive response.


here is my code

Private Sub chkbox_Click()

Dim m_id As String

sql = "select Status from Customer where Id = '" & m_id & "'"
rs.Open sql, con, adOpenDynamic, adLockOptimistic


If rs.BOF = True And rs.EOF = True Then
    
    
    Else
    
       If chkbox.Value = 1 Then
         rs!vbYesNo = "Active"
         rs.Update
         rs.Close
        Else
          rs!vbYesNo = "Not Active"
          rs.Update
          rs.Close
       End If
  End If
   
End Sub


Private Sub cmdadd_Click()
dim m_id as string

sql = "select *Customer where Id ='" & m_id & "'"
 ip_rs.Open sql, con, adOpenStatic, adLockOptimistic
 
 
 If ip_rs.BOF = True And ip_rs.EOF = True Then
   
  
 sql = "INSERT INTO Customer(Id,User_Name,Family_Name) VALUES('" & txtname.Text & "', '" & txtfname.Text & "','" & txtid.Text & "')"
 con.Execute (sql)

Recommended Answers

All 6 Replies

i don't understand correctly.
You want to add it (active or not active) to database or just for temporary only?
Do you have a field for it on database?

i don't understand correctly.
You want to add it (active or not active) to database or just for temporary only?
Do you have a field for it on database?

Hello sir, Thank you for the reply.I Forgot to put the field.The name of the field in my database is Status,and i want it Active or Not Active. if i will tick the checkbox it will
save to my status Active else Not Active.Can you help me please sir.

Thank you in advance and I am hoping for your positive response.

Hello sir, Thank you for the reply.I Forgot to put the field.The name of the field in my database is Status,and i want it Active or Not Active.

So i can conclude that you have Id,User_Name,Family_Name and Status on your customer table.

This following quote is your example on your first post :

Jemz Gimz 123 then i will check the checkbox and click the Add button
it should display on my listview
Jemz Gimz 123 Active.

In your example you looks like you want to update/edit current data on the table not to add new data on the table.
So my next question is you want to add fresh data or you want to update/edit a current data on the customer table?

So i can conclude that you have Id,User_Name,Family_Name and Status on your customer table.

This following quote is your example on your first post :

In your example you looks like you want to update/edit current data on the table not to add new data on the table.
So my next question is you want to add fresh data or you want to update/edit a current data on the customer table?

Hello sir, Yes i want to add new data sir,how could it be sir?please help me sir.

Thank you in advance and i am hoping for your positive response.

Hello sir, Yes i want to add new data sir,how could it be sir?

Really, I hope you understand what i mean.

Okay, if you want to add a new data.
Just check if the checkbox is checked then add data with status is Active and if checkbox not checked then add data with status is Not Active.

Private Sub cmdadd_Click()
Dim CheckTemp As String

If chkbox.Value = 1 Then
    CheckTemp = "Active"
Else
    CheckTemp = "Not Active"
End If

sql = "INSERT INTO Customer(Id,User_Name,Family_Name,Status) VALUES('" & txtid.Text & "','" & txtname.Text & "', '" & txtfname.Text & "','" & CheckTemp & "')"
con.Execute (sql)

End Sub

Really, I hope you understand what i mean.

Okay, if you want to add a new data.
Just check if the checkbox is checked then add data with status is Active and if checkbox not checked then add data with status is Not Active.

Private Sub cmdadd_Click()
Dim CheckTemp As String

If chkbox.Value = 1 Then
    CheckTemp = "Active"
Else
    CheckTemp = "Not Active"
End If

sql = "INSERT INTO Customer(Id,User_Name,Family_Name,Status) VALUES('" & txtid.Text & "','" & txtname.Text & "', '" & txtfname.Text & "','" & CheckTemp & "')"
con.Execute (sql)

End Sub

Hello sir thank you for helping me ,it's working.more power to you sir.

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.