Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Application crashes when..

Status
Not open for further replies.

joeythelips

IS-IT--Management
Aug 1, 2001
305
IE
Hi,

I have a command button on an ms access form which has the following code behind it:

Private Sub Command12_Click()

Dim db As Database
Dim rsmyset As Recordset
Dim MyNum As Integer
Dim MyMiss As String
Dim MyX As Integer

Set db = CurrentDb()
Set rsmyset = db.OpenRecordset("SELECT Right([RefStartup.Filename],3) AS [File No] FROM RefStartup ORDER BY Right([RefStartup.Filename],3); ", dbOpenSnapshot)
rsmyset.MoveLast
MyNum = rsmyset("file no")
rsmyset.MoveFirst
MyMiss = "0"
Do
For MyX = 100 To MyNum
If MyX = rsmyset("file no") Then
rsmyset.MoveNext
Else
MyMiss = IIf(MyMiss = "0", MyX, MyMiss & ", " & MyX)
End If
Next MyX
Loop Until rsmyset.EOF
rsmyset.Close

Set rsmyset = Nothing
Set db = Nothing
MsgBox "Alert: We are missing the following Startup Files: " & MyMiss

End Sub

However, when i clcik on the button, the application crashes.

Anyone have any ideas why?

J
 
What happens if you take () away from CurrentDb? It doesn't require them. See CurrentDb in Access help.
 
Hi,

took the() away, but still the same result
 
Use the debugger to step through your code to see which line is causing the app. to crash. Sometimes an empty recordset can do funny things.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top