When I run this function it locks Access up

L

LittleTechGuy

When I run the following Function and then close the modual, Access acts like
I closed the database. The only thing that it will let me do is Close access
and reopen the database. The function does what it is suppost to...But I can
not use it if it crashes Access all the time.

Any Ideas???

Function TestingTherory()

'On Error Resume Next
Dim dbsSecurityDatabase As Database
Dim tblLogonHoursMaster As Recordset
Dim tblLogonHoursAccts As Recordset
Dim acctexits, Found As Boolean
Dim Checkstring As String



Set dbsSecurityDatabase = OpenDatabase("TheDataBase.mdb")
Set tblLogonHoursMaster =
dbsSecurityDatabase.OpenRecordset("LogonHoursMaster", dbOpenDynaset)
Set tblLogonHoursAccts =
dbsSecurityDatabase.OpenRecordset("LogonHoursaccts", dbOpenDynaset)

tblLogonHoursMaster.MoveFirst
tblLogonHoursAccts.MoveFirst
count = 0
Do Until tblLogonHoursAccts.EOF
count = count + 1
DoCmd.Echo False, "Processing Logon Hours Account Table. User: " &
tblLogonHoursAccts.Fields("name")
Found = True
Checkstring = "username='" & tblLogonHoursAccts.Fields("name").Value
& "'"
tblLogonHoursMaster.FindFirst (Checkstring)
If tblLogonHoursAccts.Fields("name").Value =
tblLogonHoursMaster.Fields("username").Value Then
If tblLogonHoursAccts.Fields("Title").Value <>
tblLogonHoursMaster.Fields("Title").Value Or _
tblLogonHoursAccts.Fields("department").Value <>
tblLogonHoursMaster.Fields("department").Value Then
With tblLogonHoursAccts
.Edit
!Title = tblLogonHoursMaster.Fields("title").Value
!department =
tblLogonHoursMaster.Fields("department").Value
!changed = True
!acct = ""
.Update
End With
Else
With tblLogonHoursAccts
.Edit
!changed = False
.Update
End With
End If
Else
If Found = False Then
With tblLogonHoursAccts
.Delete
.Update
End With
End If
End If
tblLogonHoursAccts.MoveNext
Loop
tblLogonHoursAccts.Close
tblLogonHoursMaster.Close
dbsSecurityDatabase.Close

End Function
 
K

kingston via AccessMonster.com

What happens when you compile the procedure? Place a debug stop near the
beginning of the procedure and walk through the steps to find out which one
is causing the problem.
 
L

LittleTechGuy

Compiles fine and runs with out errors...But when you Close the Modual
Window, the Window with Table, forms, reports, etc is gone. The Menu Bar and
any tool bars are gone as well.

I can go back to the modual window and continue to work, and run...but if I
want to view the table, I have to close the whole program and reopen it to
get to the tables.
 
K

kingston via AccessMonster.com

Does this happen to any of your other databases? It sounds too wierd to be
caused by code that you wrote. Perhaps it's a corrupted library or data
table. Have you tried Compact & Repair? What led you to believe that it's
because of this function? If you run the function and do not close the
module, can you do something else in the database? Have you tried commenting
out the last line - dbsSecurityDatabase.Close?
Compiles fine and runs with out errors...But when you Close the Modual
Window, the Window with Table, forms, reports, etc is gone. The Menu Bar and
any tool bars are gone as well.

I can go back to the modual window and continue to work, and run...but if I
want to view the table, I have to close the whole program and reopen it to
get to the tables.
What happens when you compile the procedure? Place a debug stop near the
beginning of the procedure and walk through the steps to find out which one
[quoted text clipped - 72 lines]
 
L

LittleTechGuy

Just this Database, other function in the modual Access the same Tables, and
the do not cause this problem. I have Tried Compact and Repair. I tried
commenting out the first line but all I have to do is step into the function
and the problem arrises. I may just try this on anouther Machine...fresh Copy
of Access and all...?

kingston via AccessMonster.com said:
Does this happen to any of your other databases? It sounds too wierd to be
caused by code that you wrote. Perhaps it's a corrupted library or data
table. Have you tried Compact & Repair? What led you to believe that it's
because of this function? If you run the function and do not close the
module, can you do something else in the database? Have you tried commenting
out the last line - dbsSecurityDatabase.Close?
Compiles fine and runs with out errors...But when you Close the Modual
Window, the Window with Table, forms, reports, etc is gone. The Menu Bar and
any tool bars are gone as well.

I can go back to the modual window and continue to work, and run...but if I
want to view the table, I have to close the whole program and reopen it to
get to the tables.
What happens when you compile the procedure? Place a debug stop near the
beginning of the procedure and walk through the steps to find out which one
[quoted text clipped - 72 lines]
End Function
 
K

kingston via AccessMonster.com

Have you tried importing everything else into a new database to make sure
everything else works? It really sounds like you have a reference library
problem. Perhaps Access is having trouble resolving a reserved word that
belongs to multiple libraries or you have a corrupt library. Go into the VB
window and select References from the Tools menu. Check for something that
looks out of place (perhaps you installed a program recently). Update your
system and check this again. I'm sorry I can't be of more help.
Just this Database, other function in the modual Access the same Tables, and
the do not cause this problem. I have Tried Compact and Repair. I tried
commenting out the first line but all I have to do is step into the function
and the problem arrises. I may just try this on anouther Machine...fresh Copy
of Access and all...?
Does this happen to any of your other databases? It sounds too wierd to be
caused by code that you wrote. Perhaps it's a corrupted library or data
[quoted text clipped - 16 lines]
 
K

kingston via AccessMonster.com

Here's one more thing that you can try:
Close the database.
From Windows Start, select Run... and type msaccess /decompile
Open the database
Compact and Repair
Close the database
Open the database
Go into VB and compile the project
Compact and Repair
Have you tried importing everything else into a new database to make sure
everything else works? It really sounds like you have a reference library
problem. Perhaps Access is having trouble resolving a reserved word that
belongs to multiple libraries or you have a corrupt library. Go into the VB
window and select References from the Tools menu. Check for something that
looks out of place (perhaps you installed a program recently). Update your
system and check this again. I'm sorry I can't be of more help.
Just this Database, other function in the modual Access the same Tables, and
the do not cause this problem. I have Tried Compact and Repair. I tried
[quoted text clipped - 7 lines]
 

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

Top