0

hello to each and everyone..can you help me,.. can you help me on how to add a VB code on my button...what i want to happen is that when i click the button(" Vote ").. the choosen candidate in the the combo box will increment by 1 ( +1 )....
i have created a table(tblcandidate) were candidateID(Primary key),firstname,lastname and vote.. what i want agen to happen is that when a voter click the button ("Vote")the value in the vote(on tblcandidate) will +1..here is my code on my button..i need more corrections:

Private Sub Form_Open(Cancel As Integer)
Me.Combo24.SetFocus
Me.Combo26.SetFocus
End Sub

Private Sub vote_Click()
On Error GoTo Err_vote_Click
Dim Votes As Long

If IsNull(Me.Combo24) Or Me.Combo24 = "" Then
            If MsgBox("Are you Sure to leave blank in President", vbYesNo + vbExclamation, "Required Data") = vbYes Then
            Cancel = True
            Me.Undo
            Me.Combo24.SetFocus
   Exit Sub
   End If
        Else
            If IsNull(Me.Combo24) Or Me.Combo24 = "Combo24" Then
            Votes = Nz(DLookup("candidateID", "candidate", "Votes=" & Me.vote), "")
             Votes = Votes + 1
            Me.Combo24.SetFocus
            Exit Sub
            End If
             DoCmd.GoToRecord , , acNewRec
            DoCmd.OpenForm "frmProgressBar", acNormal
        Exit Sub
    End If
If IsNull(Me.Combo26) Or Combo26 = "" Then
            If MsgBox("Are you Sure to leave blank in Vice-President", vbYesNo + vbExclamation, "Required Data") = vbYes Then
            Cancel = True
            Me.Undo
            Me.Combo26.SetFocus

    Else
        If IsNull(Me.Combo26) Or Me.Combo26 = "Combo26" Then
        Me.Combo26.SetFocus
        Votes = Nz(DLookup("candidateID", "candidate", "Votes=" & Me.vote), "")
         Votes = Votes + 1
        DoCmd.GoToRecord , , acNewRec
        DoCmd.OpenForm "frmProgressBar", acNormal
        Exit Sub
    End If
Exit_vote_Click:
    Exit Sub

Err_vote_Click:
    MsgBox Err.Description
    Resume Exit_vote_Click
    End If
End If
End Sub

Edited by Nick Evan: Added code-tags, moved thread

1
Contributor
1
Reply
2
Views
6 Years
Discussion Span
Last Post by itachi_philip2
0

hello to each and everyone..can you help me,.. can you help me on how to add a VB code on my button...what i want to happen is that when i click the button(" Vote ").. the choosen candidate in the the combo box will increment by 1 ( +1 )....
i have created a table(tblcandidate) were candidateID(Primary key),firstname,lastname and vote.. what i want agen to happen is that when a voter click the button ("Vote")the value in the vote(on tblcandidate) will +1..here is my code on my button..i need more corrections:

Private Sub Form_Open(Cancel As Integer)
Me.Combo24.SetFocus
Me.Combo26.SetFocus
End Sub

Private Sub vote_Click()
On Error GoTo Err_vote_Click
Dim Votes As Long

If IsNull(Me.Combo24) Or Me.Combo24 = "" Then
            If MsgBox("Are you Sure to leave blank in President", vbYesNo + vbExclamation, "Required Data") = vbYes Then
            Cancel = True
            Me.Undo
            Me.Combo24.SetFocus
   Exit Sub
   End If
        Else
            If IsNull(Me.Combo24) Or Me.Combo24 = "Combo24" Then
            Votes = Nz(DLookup("candidateID", "candidate", "Votes=" & Me.vote), "")
             Votes = Votes + 1
            Me.Combo24.SetFocus
            Exit Sub
            End If
             DoCmd.GoToRecord , , acNewRec
            DoCmd.OpenForm "frmProgressBar", acNormal
        Exit Sub
    End If
If IsNull(Me.Combo26) Or Combo26 = "" Then
            If MsgBox("Are you Sure to leave blank in Vice-President", vbYesNo + vbExclamation, "Required Data") = vbYes Then
            Cancel = True
            Me.Undo
            Me.Combo26.SetFocus

    Else
        If IsNull(Me.Combo26) Or Me.Combo26 = "Combo26" Then
        Me.Combo26.SetFocus
        Votes = Nz(DLookup("candidateID", "candidate", "Votes=" & Me.vote), "")
         Votes = Votes + 1
        DoCmd.GoToRecord , , acNewRec
        DoCmd.OpenForm "frmProgressBar", acNormal
        Exit Sub
    End If
Exit_vote_Click:
    Exit Sub

Err_vote_Click:
    MsgBox Err.Description
    Resume Exit_vote_Click
    End If
End If
End Sub

http://www.sharetermpapers.com/computer-scienceit/computerized-voting-system-mindanao-state-university-naawan/?PHPSESSID=bc64a777752a574be95c9051c081bc88

Edited by itachi_philip2: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.