Page 3 of 4 FirstFirst 1234 LastLast
Results 31 to 45 of 56
  1. #31
    Dan Lee is offline Advanced Beginner
    Windows 10 Access 2010 64bit
    Join Date
    Jan 2017
    Posts
    57
    The car(member) voting and the car voted for can't both be del rods members. In plane English, a member cannot vote for a club member.

    There can't be duplicate votes, but the original vote and all other votes count.

    This code should work.

    Code:


    If Me.V5 = Me.V1 Or Me.V5 = Me.V2 Or Me.V5 = Me.V3 Or Me.V5 = Me.V4 Then
    Me.V5 = 0
    ElseIf Me.V4 = Me.V3 Or Me.V4 = Me.V2 Or Me.V4 = Me.V1 Then
    Me.V4 = 0
    ElseIf Me.V3 = Me.V2 Or Me.V3 = Me.V1 Then
    Me.V3 = 0
    ElseIf Me.V2 = Me.V1 Then
    Me.V2 = 0
    End

  2. #32
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    You said
    If !tRegistration.delrodsmember Or !tVote.delrodsmember Then Count Vote.
    So the car(member) voting CAN be a del rods member OR a car voted for CAN be a del rods member,
    but if the car(member) voting is a del rods member AND a car voted for is a del rods member, then the vote does not count??


    The car(member) voting and the car voted for can't both be del rods members. In plane English, a member cannot vote for a club member.
    Examples please.

    My car is 327 and I am a del rods member.
    If I vote for car 409 and they are a del rods member, does my vote count?
    If I vote for car 283 and they are NOT a del rods member, does my vote count?





    Voter Is a del rods member? Vote counts?
    Voting Car 454 yes
    Votes
    Vote 1 283
    Vote 2 327 yes
    Vote 3 383
    Vote 4 409
    Vote 5 427




    Whew, this is difficult when you don't have a car in the show!!

  3. #33
    Dan Lee is offline Advanced Beginner
    Windows 10 Access 2010 64bit
    Join Date
    Jan 2017
    Posts
    57
    If !tRegistration.delrodsmember Or !tVote.delrodsmember Then Count Vote. The ! symbol indicates Not.

    So the car(member) voting CAN be a del rods member OR a car voted for CAN be a del rods member,
    but if the car(member) voting is a del rods member AND a car voted for is a del rods member, then the vote does not count?? Yes!


    My car is 327 and I am a del rods member.
    If I vote for car 409 and they are a del rods member, does my vote count? No
    If I vote for car 283 and they are NOT a del rods member, does my vote count? Yes


    Voter Is a del rods member? Vote counts?
    Voting Car 454 yes
    Votes
    Vote 1 283 Yes
    Vote 2 327 yes No
    Vote 3 383 Yes
    Vote 4 409 Yes
    Vote 5 427 Yes

  4. #34
    Dan Lee is offline Advanced Beginner
    Windows 10 Access 2010 64bit
    Join Date
    Jan 2017
    Posts
    57
    SSANFU

    Thanks for all your help. I'm sorry if I made it more confusing that it had to be. I think that I have it all worked out. Try this.

    Private Sub btnSave_Click()
    Dim d As DAO.Database
    Dim i As Integer, x As Integer, k As Integer
    Dim sSQL As String
    Dim bFoundDups(5) As Boolean
    Set d = CurrentDb

    'clear errors labels
    For i = 1 To 5
    Me("lbl" & i).Visible = False
    Me("Label" & i).Visible = True
    bFoundDups(i) = False

    Next
    'check for duplicate car votes
    For i = 1 To 5
    For x = 1 To 5
    If i <> x Then
    If Me("V" & i) = Me("V" & x) Then
    ' MsgBox "Same " & i & " " & x
    Me("lbl" & i).Visible = True
    Me("Label" & i).Visible = False
    bFoundDups(x) = True
    bFoundDups(i) = False
    End If
    End If
    Next x
    Next i
    '
    'if dups found, do not save votes
    'append votes
    k = 0
    For i = 1 To 5
    'if (unique car member and vote) AND the voted for car IS a del Rod member
    ' If (Me("V" & i) <> Me.ubCarNumber) And Me("C" & i) Then
    If (Me("V" & i) <> Me.ubCarNumber) And Not (bFoundDups(i)) And Not Me("C" & i) Then

    sSQL = "INSERT INTO tVote2 ( BarCodeID_FK, Car_Number, CarVotedFor, VoteDate )"
    sSQL = sSQL & " VALUES ( " & Me.ubBarCode & ", " & Me.ubCarNumber & ", " & Me("V" & i) & ", #" & ubVoteDate & "#);"
    ' Debug.Print sSQL
    d.Execute sSQL, dbFailOnError
    k = k + 1
    End If
    Next
    If k > 0 Then
    MsgBox k & " votes saved!"
    End If
    'after Save clear
    Me.ubBarCode = Null
    Me.ubCarNumber = Null
    For i = 1 To 5
    Me("V" & i) = Null
    Me("C" & i) = False
    Me("lbl" & i).Visible = False
    Me("Label" & i).Visible = True
    Next
    Set d = Nothing
    End Sub

  5. #35
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Great! As long as you are happy with the results. I am going to have to think about the array - never seen it used in nested loops like that.




    For future reference: when posting code you should click on the hash in the reply menu bar. That encloses the code in code tags that keeps the formatting. Makes it easier to read
    Clicking on the hash mark adds tags to the post/reply. The tags are [ C O D E ] and [ / C O D E ]. (I had to add spaces between the characters, otherwise you wouldn't see the tags......)

    Without the code tags

    'check for duplicate car votes
    For i = 1 To 5
    For x = 1 To 5
    If i <> x Then
    If Me("V" & i) = Me("V" & x) Then
    ' MsgBox "Same " & i & " " & x
    Me("lbl" & i).Visible = True
    Me("Label" & i).Visible = False
    bFoundDups(x) = True
    bFoundDups(i) = False
    End If
    End If
    Next x
    Next i


    With the code tags
    Code:
        'check for duplicate car votes
        For i = 1 To 5
            For x = 1 To 5
                If i <> x Then
                    If Me("V" & i) = Me("V" & x) Then
                        ' MsgBox "Same " & i & " " & x
                        Me("lbl" & i).Visible = True
                        Me("Label" & i).Visible = False
                        bFoundDups(x) = True
                        bFoundDups(i) = False
                    End If
                End If
            Next x
        Next i

    Good luck with your project..... (this was fun....)

  6. #36
    Dan Lee is offline Advanced Beginner
    Windows 10 Access 2010 64bit
    Join Date
    Jan 2017
    Posts
    57
    Steve,

    I still have one problem that I need help on.

    Code:
    If (Me("V" & i) <> Me.ubCarNumber) And Not (bFoundDups(i)) And Not Me("C" & i) Then
    Not Me("C" & i) works to prevent a member from voting for a member, but it doesn't allow a non-member to vote. there should be an 'Or Something' that allows the vote to fall through.

  7. #37
    Dan Lee is offline Advanced Beginner
    Windows 10 Access 2010 64bit
    Join Date
    Jan 2017
    Posts
    57
    Is a del rods member? Vote counts?
    Voting Car 454 Yes
    Voting for
    V1 283 Yes
    V2 327 Yes No
    V3 383 Yes
    V4 409 Yes
    V5 427 Yes



    Is a del rods member? Vote counts?
    Voting Car 454 No
    Voting for
    V1 283 Yes
    V2 327 Yes Yes
    V3 383 Yes
    V4 409 Yes
    V5 427 Yes



    Is a del rods member? Vote counts?
    Voting Car 454 No
    Voting for
    V1 283 Yes
    V2 327 No Yes
    V3 383 Yes
    V4 409 Yes
    V5 427 Yes


    Car Owner Voter is Member Yes Yes No No
    Car Owner Voted for is Member Yes No Yes No

    Vote Counts No Yes Yes Yes

  8. #38
    Dan Lee is offline Advanced Beginner
    Windows 10 Access 2010 64bit
    Join Date
    Jan 2017
    Posts
    57

    tRegistration3.zip

    It was to big to upload, so I had to zip it.

    tRegistration3.zip
    Attached Files Attached Files

  9. #39
    Dan Lee is offline Advanced Beginner
    Windows 10 Access 2010 64bit
    Join Date
    Jan 2017
    Posts
    57

    tRegistration3.zip

    It was to big to upload, so I had to zip it. Ignore tRegistration3.mdb

    tRegistration3.zip

  10. #40
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Ok,try this.

    I added another function to check if the car voted for is in the registration table - in case you tried to enter 327, but you entered 324. Background turns yellow and message box.

    There was (is- but commented out) code to check if the voting car (member) is a del rods member.
    Question: If I am not a del rods member, can I cast votes??

    If NO, look in this sub "Private Sub ubBarCode_AfterUpdate()" (form name -> frmVotes)
    Look for the commented out code at the bottom of the sub
    Code:
            '        If IsMember Then
            '            For i = 1 To 5
            '                Me("V" & i).Enabled = True
            '            Next
            '            Me.btnSave.Enabled = True
            '        Else
            '            For i = 1 To 5
            '                Me("V" & i).Enabled = False
            '            Next
            '            Me.btnSave.Enabled = False
            '        End If
    Un-comment these 11 lines.
    Attached Files Attached Files

  11. #41
    Dan Lee is offline Advanced Beginner
    Windows 10 Access 2010 64bit
    Join Date
    Jan 2017
    Posts
    57
    Del Rods members can cast votes, just not for other members. I left that code commented out.

    There is a problem with the registration table. In the voting form, Voting Car Number doesn't get inserted if the Bar Code is a 3 digit number. It does get inserted, if a single digit number, even if the Bar Code & Car Number are different. It should not be checking Bar Code, only Car Number. Bar Codes & Car Numbers can be different.

  12. #42
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Del Rods members can cast votes, just not for other members. I left that code commented out.
    And non Del Rods members (for instance me) can cast votes for anyone, member or not, if I have a car entered in the event?


    Voting Car Number doesn't get inserted if the Bar Code is a 3 digit number. It does get inserted, if a single digit number, even if the Bar Code & Car Number are different.
    I don't understand this. I changed the bar codes; there are bar codes of 1, 50, 200 and 6000. All bar codes and car codes get entered into the votes table.

    See dB 5
    Attached Files Attached Files

  13. #43
    Dan Lee is offline Advanced Beginner
    Windows 10 Access 2010 64bit
    Join Date
    Jan 2017
    Posts
    57
    Quote Originally Posted by ssanfu View Post
    And non Del Rods members (for instance me) can cast votes for anyone, member or not, if I have a car entered in the event?

    Yes, non members can vote for any.

  14. #44
    Dan Lee is offline Advanced Beginner
    Windows 10 Access 2010 64bit
    Join Date
    Jan 2017
    Posts
    57
    I think it works now, but I commented 'Exit Sub' out.

    Code:
    If Nz(Me.ubCarNumber, 0) = 0 Then
            MsgBox "Missing car number" & vbNewLine & vbNewLine & "Aborting"
            Me.ubBarCode.SetFocus
           ' Exit Sub
        End If
    I also commented out this
    Code:
    'Private Sub ubBarCode_GotFocus()
     '   Me.lstBarCar.Visible = True
    'End Sub
    'Private Sub ubBarCode_LostFocus()
     '   Me.lstBarCar.Visible = False
    'End Sub
    I liked the old Vote Form better, this is too busy. Can you go back to the old form?

  15. #45
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Double click in the light blue header area..

    I added the votes at the bottom so the entries could be checked... But if you really want the green form, I'll switch it back.


    If the car number is Null (not entered) or 0, the rest of the code in the save sub shouldn't execute. Hence the Exit Sub.


    Here is the green form.......
    Attached Files Attached Files

Page 3 of 4 FirstFirst 1234 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. 30 day registration for access
    By CHEECO in forum Access
    Replies: 7
    Last Post: 06-05-2016, 12:31 PM
  2. Using access registration details
    By BSJoJaMAx4 in forum Access
    Replies: 7
    Last Post: 10-05-2015, 06:05 PM
  3. registration database
    By hodagh in forum Queries
    Replies: 7
    Last Post: 11-05-2012, 12:52 PM
  4. Registration of Attendees
    By camende in forum Programming
    Replies: 1
    Last Post: 06-30-2010, 03:47 PM
  5. Registration Form
    By nengster in forum Forms
    Replies: 0
    Last Post: 02-16-2009, 04:22 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums