Still struggling with DataEntry attribute


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
 
Ad

Advertisements

L

Laurel

OK!!!!! After staying up all night, I finally fixed the sucker. I'm still
not sure exactly where the problem was, but here's what I did.

1 - Played with it enough to know that I could make the problem go away by
toggling the DataEntry property, and maybe the "allowed" properties, and
maybe compress/repair. BUT... whenever I exited the database and returned
the problem was there again. (Good I discovered this before shipping the
"fixed" copy to the user.)
2 - Tried various "corruption cures" from
http://www.granite.ab.ca/access/corruptmdbs.htm
3 - The one that finally worked was to import objects from the bad database
into a brand new empty database.
4 - I started with just the tables and a brand new form. I placed brand new
objects on the form, for the most part, but 3 times I had to start over
because toward the end, when I started copying truly innocent (but
painstakingly beutified) controls over, and/or pieces of the code, the
problem returned. I do believe that one essential piece was to save the
code below in NotePad, and then copy it into the script area, little piece
by littel piece. (Note- I kept it really simple, and this was the only code
in the form.)
5 - SO! I had a good working form again, so I proceeded to import all of
the other objects. Blam! After I was done my form was brokein.
6 - Started from step 3 over again. When I had my new form working again, I
imported the objects one or two at a time and tested my form each time. I
left behind obsolete objects. There weren't many, but now I do believe I
have a stable form that doesn't toggle its dataentry attribute.

May no one ever need to use this information!!!!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Still Struggling... 88
disable dataentry if date < today 2
Struggles for the "visual" people 7
Struggling! Please help! 0
Struggling with current record 10
Still stuck 5
Problem is still present 1
still cannot found 4

Top