|
|
Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
I have a form with 4 unbound text boxes and a button. The RecordSource for the form uses values in the text boxes. When I open the form, all is fine. No rows show because the criteria are all null and there are no rows in the database that match that situation (at least I assume that's why no rows show up.) I set "No Additions" to True in my code, so no empty row shows up either. Once I've entered values, if the user clicks the button, then, after a bunch of other stuff, a Me.Requery is executed and rows show up.
My problem happens after I set one of the values to -999 and execute another Me.Requery, to empty out the form of rows so the user can start over. (No rows will be returned with that value). After I do that, whenever I click on any of the unbound text boxes or the button, I get a "No current record" message. I don't have to enter any data, pull down a dropdown or anything. And the message doesn't seem to affect the rest of the performance of the form. The user can enter new data, click the button, and get a new set of records. As far as I can see this "No current record" is not tied to any code I've written. In other words, I can't find the actual event where the message is being displayed in the debugger.
If I click the same text box or button a second time, the message doesn't appear.
Again - I don't need to enter data or pull down the dropdown for the error to happen. Just "click". The only code I have associated with the text boxes is "after_update" - nothing in "click".
Here's the routine that causes the problem. It is executed from the after_update events on the controls. If I comment out the Me.Requery at the bottom, the problem goes away.
Any ideas?
Private Sub SetControlStates() 'This function serves as a template for other new functions Dim ls_temp As String
On Error GoTo Err_SetControlStates
'First test for non-description re-entered on already loaded form (need new description) If (cmdGO.Enabled = True) And (ib_DescriptionEntered = False) Then [txtDescription] = "" cmdGO.Enabled = False GoTo RequeryPlace Else 'Either description entered, or first time entry If (Not (IsNull(txtGrade_Date))) And (Not (IsNull(cboSubject_Code))) _ And (Not (IsNull(cboType))) And (Not (IsNull(cboClass_Code))) _ And (Not (IsNull(txtDescription)) Or (Trim(txtDescription) = "")) Then cmdGO.Enabled = True Else cmdGO.Enabled = False End If End If
RequeryPlace: If Not (Me.Recordset.BOF And Me.Recordset.EOF) Then 'Empty out old records [txtCriterion] = "-999" ' Me.Requery Else
End If Exit_SetControlStates: Exit Sub
Err_SetControlStates: ls_temp = "SetControlStates:" _ & vbCrLf & " " & Err.Description MsgBox ls_temp
Resume Exit_SetControlStates End Sub
|
|
|