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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run Time Error 3001

Status
Not open for further replies.

BoxerBrats

Programmer
Jul 1, 2003
9
0
0
US
ok new to all this but when I goto run my program I keep getting a runtime error '3001'

below is my code

Private Sub Form_Load()
'**** Connect to database
Dim strConnection As String
Dim path As String
path = App.path & "\Database.mdb"

'**** Set path for location of database
strConnection = "driver={Microsoft Access Driver (*.mdb)};dbq=" & App.path & "\Data\Database.mdb" & ";uidpwd"

Set conDB = New ADODB.Connection
conDB.Open strConnection

'**** Set all new recordsets
Set rstEquipment = New ADODB.Recordset
Set rstVehicleData = New ADODB.Recordset
Set rstVehicleMiles = New ADODB.Recordset
Set rstWorkOrder = New ADODB.Recordset
Set rstParts = New ADODB.Recordset
Set rstPartsHistory = New ADODB.Recordset
Set rstPO = New ADODB.Recordset
Set rstVendors = New ADODB.Recordset
Set rstLabor = New ADODB.Recordset
Set rstOfficeEquipment = New ADODB.Recordset
Set rstBuildingEquipment = New ADODB.Recordset
Set rstUser = New ADODB.Recordset


End Sub


Private Sub cmdEnter_Click()
'**** stop blank entry
If txtUserName = "" Then
Prompt$ = "You have to enter your login name"
reply = MsgBox(Prompt$, 48, "Blank Login Name")
txtUserName.SetFocus

'**** SET BACK DOOR
ElseIf txtUserName.Text = "6783" Then
User = "BackDoor"
Password = 496
UserLevel = "Admin"
AccessLevel = 1
Timer1.Enabled = True

Else
'**** set user name
User = txtUserName.Text

'Check whether user exist in the database
rstUser.Open "SELECT * FROM User WHERE User.LoginName ='" & User & "'", conDB, adOpenStatic, adLockReadOnly"

If Not rstUser.EOF Then

'Check whether password is correct
If (Password = rstUser!UserPassword) Then
'Assign user level to global variable
UserLevel = rstUser!UserLevel
AccessLevel = 1
Timer1.Enabled = True
Else

MsgBox "Logged on failed - Invalid Password", vbCritical, "Login"
End If
Else
MsgBox "Logged on failed - Invalid User", vbCritical, "Login"

End If

End If
End Sub


any help would be great thanks
 
This was also asked in the VB Database forum.

"User" is a reserved word - enclose it in brackets
 
BoxerBrats

Check out faq222-2244 to see why cross posting is discouraged in this forum (and on the whole site)

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
I didn't get which line you were having the problem on but I had a similar error on a line starting with:

Set rsDateLast = New ADODB.Recordset
rsDateLast.Open SQL1 = "SELECT Max(Month_LastDay_Year) AS MaxLDY FROM tblAdmitMonthYear_Lookup", CurrentProject.Connection, adOpenKeyset, adLockOptimistic

I figured out that it doesn't like me to use rsDateLast. If I changed that variable to rsDateLasts, it worked. If you are getting this in your rstUser, try changing it.




 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top