L
Laurel
This is what I see in the immediate window after running my form four times,
using the same retrieval arguments (script at end of this post). In all
cases it behaves as if DataEntry = True (i.e., I only see an empty new
record when I should see two records.) Can anyone see what, in the code
below, might cause the DataEntry value to be unstable? I had this problem
in another form, and I have re-created this one step by step. It seems
clear that the code below is one thing that causes the problem. If I
execute a very simple script for requery, then it behaves as if DataEntry =
False. All of the "allow" attributes are set to "Yes," although earlier,
before putting in this script, I did see the problem show up when I was
changing the AllowAdds and AllowDeletes. Maybe playing with those
attributes corrupts the form.. ??
Note - in another post I reported that I fixed this problem by putting in a
Me.DataEntry = False... But that fix just went away.... without my having
modified the form. This is not unusual... The behavior seems to change
simply by virtue of my getting out of the db... or maybe by virtue of
rebooting. That feels more like it. I get up in the morning and the "fix"
from the night before is gone.
Note also, I was advised to rebuild the form and/or database. I did import
it into a copy of the database (from which it had been deleted), and the
problem persisted. As I type, I figure I'd better export it into a brand
new database..... But I'll go ahead and post this anyway, in case someone
has seen something like this.
BFalse
EFalse
FFalse
AFalse
BFalse
EFalse
FFalse
ATrue
BTrue
ETrue
FTrueAFalse
BFalse
EFalse
FFalse
Private Sub cmdGo_Click()
On Error GoTo cmdGo_Click_Err
Dim rstClassList As RecordSet
Dim ls_sql As String
Dim ls_where As String
Dim li_return As Integer
If fncCheckDefaultData <> "OK" Then
cboClassCode.SetFocus
Else
Debug.Print "A" & Me.DataEntry
ls_sql = "Select * from tblStudents Where class_code = '" & cboClassCode
& "'"
Set rstClassList = CurrentDb.OpenRecordset(ls_sql)
Debug.Print "B" & Me.DataEntry
With rstClassList
.MoveLast
.MoveFirst
Do Until .EOF
ls_where = "Student_ID = " & rstClassList!Student_ID & _
" AND Att_Date = #" & txtAtt_Date & "#"
li_return = DLookup("Count(*)", "tblAttendance", ls_where)
If li_return = 0 Then
ls_sql = "INSERT INTO tblAttendance (Att_Date,Student_ID)" _
& " Values(#" & txtAtt_Date & "#, " & !Student_ID &
")"
Debug.Print "C" & Me.DataEntry
CurrentDb.Execute ls_sql
Debug.Print "D" & Me.DataEntry
End If
.MoveNext
Loop
Debug.Print "E" & Me.DataEntry
Detail.Visible = True
Debug.Print "F" & Me.DataEntry
End With
End If
cmdGo_Click_Exit:
Exit Sub
cmdGo_Click_Err:
MsgBox Error$
Resume cmdGo_Click_Exit
End Sub
Private Sub Form_Open(Cancel As Integer)
' DoCmd.Maximize
End Sub
Private Sub Form_Load()
Detail.Visible = False
End Sub
using the same retrieval arguments (script at end of this post). In all
cases it behaves as if DataEntry = True (i.e., I only see an empty new
record when I should see two records.) Can anyone see what, in the code
below, might cause the DataEntry value to be unstable? I had this problem
in another form, and I have re-created this one step by step. It seems
clear that the code below is one thing that causes the problem. If I
execute a very simple script for requery, then it behaves as if DataEntry =
False. All of the "allow" attributes are set to "Yes," although earlier,
before putting in this script, I did see the problem show up when I was
changing the AllowAdds and AllowDeletes. Maybe playing with those
attributes corrupts the form.. ??
Note - in another post I reported that I fixed this problem by putting in a
Me.DataEntry = False... But that fix just went away.... without my having
modified the form. This is not unusual... The behavior seems to change
simply by virtue of my getting out of the db... or maybe by virtue of
rebooting. That feels more like it. I get up in the morning and the "fix"
from the night before is gone.
Note also, I was advised to rebuild the form and/or database. I did import
it into a copy of the database (from which it had been deleted), and the
problem persisted. As I type, I figure I'd better export it into a brand
new database..... But I'll go ahead and post this anyway, in case someone
has seen something like this.
BFalse
EFalse
FFalse
AFalse
BFalse
EFalse
FFalse
ATrue
BTrue
ETrue
FTrueAFalse
BFalse
EFalse
FFalse
Private Sub cmdGo_Click()
On Error GoTo cmdGo_Click_Err
Dim rstClassList As RecordSet
Dim ls_sql As String
Dim ls_where As String
Dim li_return As Integer
If fncCheckDefaultData <> "OK" Then
cboClassCode.SetFocus
Else
Debug.Print "A" & Me.DataEntry
ls_sql = "Select * from tblStudents Where class_code = '" & cboClassCode
& "'"
Set rstClassList = CurrentDb.OpenRecordset(ls_sql)
Debug.Print "B" & Me.DataEntry
With rstClassList
.MoveLast
.MoveFirst
Do Until .EOF
ls_where = "Student_ID = " & rstClassList!Student_ID & _
" AND Att_Date = #" & txtAtt_Date & "#"
li_return = DLookup("Count(*)", "tblAttendance", ls_where)
If li_return = 0 Then
ls_sql = "INSERT INTO tblAttendance (Att_Date,Student_ID)" _
& " Values(#" & txtAtt_Date & "#, " & !Student_ID &
")"
Debug.Print "C" & Me.DataEntry
CurrentDb.Execute ls_sql
Debug.Print "D" & Me.DataEntry
End If
.MoveNext
Loop
Debug.Print "E" & Me.DataEntry
Detail.Visible = True
Debug.Print "F" & Me.DataEntry
End With
End If
cmdGo_Click_Exit:
Exit Sub
cmdGo_Click_Err:
MsgBox Error$
Resume cmdGo_Click_Exit
End Sub
Private Sub Form_Open(Cancel As Integer)
' DoCmd.Maximize
End Sub
Private Sub Form_Load()
Detail.Visible = False
End Sub