I'm having a problem with requerying a form's data values from code, with the line shown in red.
The line works perfect 99% of the time, but after the green statements fire it breaks when data is reentered and gives me Err 2001: Operation canceled by you (I think that's the error message, it's in portuguese so I'm not sure).
The problem is not in the query, or in data being added to the table after it's null, because in case 1 of the select statement, the same query runs and the program keeps working perfectly afterwards.
Private Sub Form_Timer()
Form_conTudo1.Requery
conEsqBC_subformulário.Requery
conDirBC_subformulário.Requery
If (DCount("*", "conSequencia") > 1) Then
MsgBox "Error! Mais duma Sequência entrada. Scan sequência de novo", vbOKOnly, "ERROR"
DoCmd.OpenQuery elimTudo
GoTo Exit_cmdVerificar_Click
End If
On Error GoTo Err_Sair
...Do Stuff...
'Case 1: both values correct
'Case 2: Left value not null and incorrect, right value correct or null
'Case 3: Right value not null and incorrect, left value correct or null
'Case 4: Both values not null and incorrect
'case else: both values null, or unexpected
Select Case controlFlag
Case 1: Form_conTudo1.imgLuz.Picture = Path & verde
msg = "Bom trabalho, os farois estão correctos. Faz a proxima peça!"
RESPUESTA = MsgBox(msg, vbOKOnly, title)
DoCmd.OpenQuery insOK
DoCmd.OpenQuery elimTudo
Case 2: msg = "O farois do esquerdo está fodido."
RESPUESTA = MsgBox(msg, vbOKOnly, title)
DoCmd.OpenQuery elimEsq
Case 3: msg = "O farois do dereito está fodido."
RESPUESTA = MsgBox(msg, vbOKOnly, title)
DoCmd.OpenQuery elimDir
Case 4: msg = "Estupido caralho, ambos farois estão fodidos."
RESPUESTA = MsgBox(msg, vbOKOnly, title)
DoCmd.OpenQuery elimEsq
DoCmd.OpenQuery elimDir
Case Else:
End Select
Exit_cmdVerificar_Click:
Exit Sub
Err_Sair:
MsgBox Err.Description
Resume Exit_cmdVerificar_Click
End Sub
The line works perfect 99% of the time, but after the green statements fire it breaks when data is reentered and gives me Err 2001: Operation canceled by you (I think that's the error message, it's in portuguese so I'm not sure).
The problem is not in the query, or in data being added to the table after it's null, because in case 1 of the select statement, the same query runs and the program keeps working perfectly afterwards.
Private Sub Form_Timer()
Form_conTudo1.Requery
conEsqBC_subformulário.Requery
conDirBC_subformulário.Requery
If (DCount("*", "conSequencia") > 1) Then
MsgBox "Error! Mais duma Sequência entrada. Scan sequência de novo", vbOKOnly, "ERROR"
DoCmd.OpenQuery elimTudo
GoTo Exit_cmdVerificar_Click
End If
On Error GoTo Err_Sair
...Do Stuff...
'Case 1: both values correct
'Case 2: Left value not null and incorrect, right value correct or null
'Case 3: Right value not null and incorrect, left value correct or null
'Case 4: Both values not null and incorrect
'case else: both values null, or unexpected
Select Case controlFlag
Case 1: Form_conTudo1.imgLuz.Picture = Path & verde
msg = "Bom trabalho, os farois estão correctos. Faz a proxima peça!"
RESPUESTA = MsgBox(msg, vbOKOnly, title)
DoCmd.OpenQuery insOK
DoCmd.OpenQuery elimTudo
Case 2: msg = "O farois do esquerdo está fodido."
RESPUESTA = MsgBox(msg, vbOKOnly, title)
DoCmd.OpenQuery elimEsq
Case 3: msg = "O farois do dereito está fodido."
RESPUESTA = MsgBox(msg, vbOKOnly, title)
DoCmd.OpenQuery elimDir
Case 4: msg = "Estupido caralho, ambos farois estão fodidos."
RESPUESTA = MsgBox(msg, vbOKOnly, title)
DoCmd.OpenQuery elimEsq
DoCmd.OpenQuery elimDir
Case Else:
End Select
Exit_cmdVerificar_Click:
Exit Sub
Err_Sair:
MsgBox Err.Description
Resume Exit_cmdVerificar_Click
End Sub