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
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