Voting system in Microsoft Access

0

Good morning, I just need you to help me with a code.

I need to make a voting system, I already have the table ready but my code does not do what I asked.

There are two questions:

A) How do I correctly validate that the user has checked a checkbox? B) How do I add a vote to the voter in question?

This is what I have so far:

-Code:

 Private Sub Comando25_Click()
 Check1 As Boolean
 Check2 As Boolean
 Check3 As Boolean
 Check4 As Boolean

 If Me.Check1 = True & Me.Check2 = True & Me.Check3 = True & Me.Check4 = True 
 Then
 MsgBox "No puedes seleccionar los cuatro, solo puedes seleccionar uno"
 DoCmd.Close
 DoCmd.OpenForm "Ir a"
 End If

 If Me.Check1 = True & Me.Check2 = True & Me.Check3 = True Then
 MsgBox "No puedes seleccionar tres, solo puedes seleccionar uno"
 DoCmd.Close
 DoCmd.OpenForm "Ir a"
 End If

 If Me.Check1 = True & Me.Check2 = True Then
 MsgBox "No puedes seleccionar dos, solo puedes seleccionar uno"
 DoCmd.Close
 DoCmd.OpenForm "Ir a"
 End If

 If Me.Check2 = True & Me.Check3 = True Then
 MsgBox "No puedes seleccionar dos, solo puedes seleccionar uno"
 DoCmd.Close
 DoCmd.OpenForm "Ir a"
 End If

  If Me.Check1 = True & Me.Check3 = True Then
MsgBox "No puedes seleccionar dos, solo puedes seleccionar uno"
DoCmd.Close
DoCmd.OpenForm "Ir a"
End If
End Sub

This is what the form looks like:

This is how the table looks: (Votes is a variable number, of course)

I await your response

    
asked by Shredder 22.10.2017 в 23:19
source

1 answer

0

You tried to put together a table to record the votes in which there are only two columns: the Id and the answer based on a search list that you could place right in the middle of the 4 faces as a subform of your form)?

And where you can only choose 1 of the 4 that are listed, that would avoid all the limits you try to put on it. The other is that you can only put a number that you like best between 1 and 4, nothing prevents print your vote with all the candidate's data, either to go to the box or kept by himself.

Ideally, it would be a multiple option yes / No, so far as I know, you could only do it with Visual. But that's what I refuse to know

    
answered by 23.10.2017 в 01:23