Marchese Il Chihuahua
Marchese Il Chihuahua

Reputation: 1129

Strange issue with an update query

I am trying to create a button that updates the field "objectivesdialnumber" changing the number from 1 thru 6 and back to 1. Unfortunately, it is not working and i don't understand why. I have written other queries in this format and they Always work.

Private Sub Comando36_Click()

    If [objectivesdialnumber] = 1 Then
     [objectivesdialnumber] = 2
    ElseIf objectivesdialnumber = 2 Then
     objectivesdialnumber = 3
    ElseIf objectivesdialnumber = 3 Then
     objectivesdialnumber = 4
    ElseIf objectivesdialnumber = 4 Then
     objectivesdialnumber = 5
    ElseIf objectivesdialnumber = 5 Then
     objectivesdialnumber = 6
    ElseIf objectivesdialnumber = 6 Then 
     objectivesdialnumber = 1

  End If


End Sub

Upvotes: 1

Views: 31

Answers (1)

Barranka
Barranka

Reputation: 21047

A little trick that will spare you all those ifs.

You can use Mod to squeeze all those comparissons:

txtObjectivesDialNumber = (CInt(txtObjectivesDialNumber) Mod 6) + 1

Consider Remou's comment and rename your control

Upvotes: 1

Related Questions