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!

Runtime 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
 
Which line is highlighted in your code when "3001 Invalid argument." is raised?
 
this is the line with the error in it

rstUser.Open "SELECT * FROM User WHERE User.LoginName ='" & User & "'", conDB, adOpenStatic, adLockReadOnly"


thanks you for any help you can give me
 
"User" is a reserved word
[User] WHERE [User].LoginName
 
thank you for the help, but still having trouble with the same error on the same line

I changed the line to

rstUser.Open "SELECT * FROM UserID WHERE LoginName = '" & UserName & "'", conDB, adOpenStatic, adLockReadOnly

I would appreciate any suggestions here

thank you
 

Is "UserID" now the name of the table?

You should also use the JET provider instead of the ODBC driver for JET/ACCESS:

conn.Open "Provider=Microsoft.Jet.OLEDB.4.0" _
& ";Data Source=" & App.path & "\Data\Database.mdb" _
& ";Jet OLEDB:Database Password" = "123456789"
 
Yes changed the table name to UserID with hopes of stopping any conflict
 

Is it possible conDB is a local variable in the the Form_load subroutine. I mean, have you dimensioned (dim) conDB in the form general section?

Dim conDB as ADODB.Connection

Sub Form_Load
' will automatically dim a conDB
' if Option Explicit is not declared and
' conDB not a form level variable
Set conDB = New ADODB.Connection
End Sub




Mark

"You guys pair up in groups of three, then line up in a circle."
- Bill Peterson, a Florida State football coach
 
It may be one of the parameters used with the Open statement.
I do not use the ACCESS ODBC driver (for many ugly reasons - this MAY be an addition to the list).

Try it with w/o specifying the cursor type and lock type.

If that doesn't get you any further then try it with the JET Provider and report your findings.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top