gary_getter1
01-30-2007, 07:20 PM
I want to create a database need user login the system at first, i try to use a function to handle the checking, but it return "Type mismatch" & Runtime error "Operation is not allow when the object is closed", i am not sure my code is all right, can anyone help me to find out what the problem in my program?
Thx a lot!
Dennisk
01-31-2007, 12:17 AM
Are you trying to develop a login system, if so then don't bother. Firstly Access comes with workgroup protection although it can be difficult to set up at first. Any user written password system can always be bypassed or broken into. The last db I looked at had a user developed login system and even though the bypass key had been disabled I was able to invoke the debugger and get into the login form that way.
gary_getter1
01-31-2007, 07:06 PM
Are you trying to develop a login system, if so then don't bother. Firstly Access comes with workgroup protection although it can be difficult to set up at first. Any user written password system can always be bypassed or broken into. The last db I looked at had a user developed login system and even though the bypass key had been disabled I was able to invoke the debugger and get into the login form that way.
Thank for your opinion.
But i am not worry my user will bypass the user checking, because my user just need a data system to help them to search the data, and give the different button to select different from to view the needed data.
And now i find out the error happened on the connection to CurrentProject.
------------------------------------------------------------------------
Public Function GetRS(ByVal strQuery As String) As ADODB.Recordset
Dim rs As New ADODB.Recordset
Dim conn As New ADODB.Recordset
'On Error GoTo GetRS_Error
Set conn = CurrentProject.Connection
rs.Open Trim$(strQuery), conn, adOpenKeyset, adLockOptimistic
Set GetRS = rs
End Function
-------------------------------------------------------------------------
The debugger show me that conn = <Object variable or with block variable not set.> & CurrentProject.Connection = Provider= Microsoft.Jet.OLEDB.4.0;UserID=Admin;Data...
what should i do to correct it?
Dennisk
02-01-2007, 12:19 AM
you need to open the connection
i.e.
dim conn as new ADODB.connection
conn.open currentProject.connection
or in the table open statement
rst.open mytable,Currentproject.Connection
using this method there is no need for the extra connection object
gary_getter1
02-01-2007, 05:03 PM
Thank for you help.
Yup, i forgot to set the connection on Dim statement, but there have another error when i solve out the connection, access alert me that a Run-time error as follow:
Run-time error '-2147217900(80040e14)': Syntax error in FROM clause.
and the debugger point out the error come from:
rs.Open Trim$(strQuery), conn, adOpenKeyset, adLockOptimistic
-------------------------------------------------------------------------
Public Function GetRS(ByVal strQuery As String) As ADODB.Recordset
Dim rs As New ADODB.Recordset
Dim conn As New ADODB.Connection
Set conn = CurrentProject.Connection
rs.Open Trim$(strQuery), conn, adOpenKeyset, adLockOptimistic
Set GetRS = rs
GetRS_Exit:
Set rs = Nothing
Set conn = Nothing
Exit Function
End Function
--------------------------------------------------------------------------
Dennisk
02-02-2007, 12:48 AM
Hi,
That message is telling you that there is an error in strQuery.
Also There is probally no need to trim your SQL statement.