this is the code for my module, i dont know what is really my problem.. can anyone help me? the error said "The Microsoft Jet Database engine cannot find the input table or query 'tblLogIn'. Make sure it exist and its name is spelled correcty..
Code:
'Login
Sub initLogForm(ByRef conConnection As ADODB.Connection, ByRef cmdCommand As ADODB.Command, ByRef rsRecordset As ADODB.Recordset, ByRef sqlString As String)
conConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\inventory system\inventory system.mdb;Persist Security Info=false"
conConnection.CursorLocation = adUseClient
conConnection.Open
With cmdCommand
.ActiveConnection = conConnection
.CommandText = sqlString
.CommandType = adCmdText
End With
With rsRecordset
.CursorType = adOpenStatic
.CursorLocation = adUseClient
.LockType = adLockOptimistic
.Open cmdCommand
End With
End Sub
Well you did not show us the sqlString which is where the problem would be. The error insicates a problem with the table name in the sqlString.
If your string is something like
Code:
Select * from 'tblLogIn' .....
Then that would be the source of the problem. No quotes should be used on table names it should be like
Code:
Select * from tblLogIn .....
this is my code for log in button
Code:
Private Sub Command1_Click()
'Correct BackColor
Text2.BackColor = &HFFFFFF
Text3.BackColor = &HFFFFFF
Dim conConnection As New ADODB.Connection
Dim cmdCommand As New ADODB.Command
Dim rsRecordset As New ADODB.Recordset
Dim sqlString As String
sqlString = "SELECT * FROM tblLogIn WHERE Username like '" & Text2.Text & "'"
initLogForm conConnection, cmdCommand, rsRecordset, sqlString
If rsRecordset.EOF = False Then
'Checking the form
With Text2
If .Text = "" Then
MsgBox "Please Fill the Form"
.BackColor = &H80FFFF
.Text = ""
.SetFocus
End If
End With
With Text3
If .Text = "" Then
MsgBox "Please Fill the Form"
.BackColor = &H80FFFF
.Text = ""
.SetFocus
End If
End With
'Check the username if is correct
If rsRecordset.Fields(1) = Text2.Text And rsRecordset.Fields(2) = Text3.Text Then
Main.Show 'show of splash screen
UserType = rsRecordset.Fields(3)
If UserType = "User" Then
End If
Unload Me
Else
MsgBox "Incorrect Username or Password!"
End If
Else
'If the username is invalid / wrong
'If record is not found message displays
MsgBox "Incorrect login or password! Please try again.", vbCritical, "Password Error Message"
'count number of tries
try = try + 1
'Allows only 3 tries, then application stops
If try >= 3 Then
MsgBox "CAUTION: you entered 3 try. This System will be automatically terminated, Thank you and Goodbye!!!", vbOKOnly, "WARNING: Password Error Message"
End
End If
Text2.SetFocus
Exit Sub
End If
xnitLogForm conConnection, cmdCommand, rsRecordset
Text3.Text = ""
On Error GoTo ErrorHandler
Exit Sub
ErrorHandler:
MsgBox "Error Number: " & Err.Number & " With The Description ->> " & Err.Description & " <<- Occured."
End Sub
add a line just above the open statement where you are getting an error
Code:
Debug.Print sqlString
and see what prints out in the debug window then let us know.
It is possible that there is another issue in that string but the error is pretty specific.
add a line just above the open statement where you are getting an error
Code:
Debug.Print sqlString
and see what prints out in the debug window then let us know.
It is possible that there is another issue in that string but the error is pretty specific.
It you put that line in the code right above where the error was occurring then it would have written something to your debug window. If it did not then that would mean either you are getting an error somewhere else or you are not looking at the debug/immediate window or you entered it incorrectly.
The immediate window is in the program you are using to write your application. It shows at the bottom. When you use Debug.Print, it prints the result of the Debug.Print statement there, not in your application nor in a messagebox. When you run your program, you will see the VB development area BEHIND YOUR program. If you look in the bottom left corner, as per the screenshot I include, you will see the result of the Debug.Print
the error number is talking about that the connection has failed or disconnected.
check ur connection database..
The first post says that the error message was
the error said "The Microsoft Jet Database engine cannot find the input table or query 'tblLogIn'. Make sure it exist and its name is spelled correcty..
This does not indicate a failed connection. It indicates a bad table name in the sekect string.
What is the exact error message that is appearing when you run the program now?
ops soryy, not read the first thread,,
when i saw the err number its look like the connection error number,,
but when i check my program its different..
if it so ,well he should check the table name and the database right ??
it is connected to my database, and the table name is correct.. but still it has an error saying : "The Microsoft Jet Database engine cannot find the input table or query 'tblLogIn'. Make sure it exist and its name is spelled correcty.."
Can you paste your latest code (or attach it), hopefully including the Debug.print line of code.
Forgive me for not reading all the above posts (I just woke up).
Are you using Option Explicit ?
Are you running the program by doing ALT fsrf
(Holding down the ALT key and asking for File Save Run with Full compile)
Can you prepare a trimmed down copy of your program, that demonstrates the same problem, and attach it for us to run ourselves.
GUARANTEED to help solve the problem
So based on the error message it sounds like that table is not in the database you are connecting to. You should double check the path and open the db at that location and make sure that the table is there and that the spelling is correct. This is the most likely source of the problem.
Beyond that you need to learn how to use the debugger, to step through the code, look at the values of variables and use the debug.print if needed to show a value in the immeadiate window.
If the error occured on the line you have highlighted in your first post and you placed that debug.print line directly above the line where the error occurred then run the program you will most certianly get an output in the debug window.
So either you did not put it in the right place or the error is not occurring on the indicated line.
Can you paste your latest code (or attach it), hopefully including the Debug.print line of code.
Forgive me for not reading all the above posts (I just woke up).
Are you using Option Explicit ?
Are you running the program by doing ALT fsrf
(Holding down the ALT key and asking for File Save Run with Full compile)
Can you prepare a trimmed down copy of your program, that demonstrates the same problem, and attach it for us to run ourselves.
GUARANTEED to help solve the problem
sir, i attached my whole system that i am making.. the error is on the log in form.. or form1. please help me,
I'm in a bit of a pickle at the moment.
I will list the problems I found soon.
One of the later problems was not using meaningful names for the textboxes EG Text2 and Text3
Whilst doing global renames of those in the code, I stuffed it.
So I am starting afresh with your code, and doing the fixes again.
Bear with me, whilst I am doing that
Before running it ensure that you rename the DB and the folder, TO GET RID OF SPACES, and case possible problems. EG -
D:\Inventory_system\Inventory_system.mdb
Don't use spaces in any names
Don't use names that can confuse VB6 or me
Make the Form internal name the same as the file name
tblLogin should be Login
Use meaningful names for controls such as txtUsername and txtPassword
I have gotten rid of Fields(3) whatever, and used the bang character !
!Username
When you do that, and have meaningful textbox names, you could not get them mixed up, even if you were both drunk and high (or old like me).
Last edited by Bobbles; Jun 12th, 2012 at 11:35 PM.
There were a few potential problems, and conventions(lack thereof) that could have been causing problems, or by their nature were extremely prone to causing problems.
My main focus was to fix those poor areas, and then run it with full compile, fixing lines where it crashed.
My post 29 covers most of the areas I 'fixed'
I also replaced the connection code, rather than try to fix it.
Thus, I did not try to nail down what exactly was causing the error(s), I was just trying to fix it all.
aldryn05 probably has studied my code, and compared it to his, so he might be in a better position to describe what he thinks was causing the error(s)
Regards,
Rob
Last edited by Bobbles; Jun 13th, 2012 at 11:23 AM.
I was just curious as the initial post said that the error was complaining about the table name not being there and then he said that the debug.print sqlstring did not show anything.
Was the table actually Named Login or was it tblLogin in the database?
I was just curious as the initial post said that the error was complaining about the table name not being there and then he said that the debug.print sqlstring did not show anything.
Was the table actually Named Login or was it tblLogin in the database?
You're right on to it.
The Table name in the DB was Login, and correcting tblLogin to Login was one of the code changes I made.
HEHEHE, im sorry.. but, thanks! i just thought that when you're into table.. you should include tbl to your fieldname..
No problem, and yes it is good to include tbl in your naming convention but your code must match the database or it will not work
For example if I were writing an app that had a login feature most likely the table would be named tblUsers and when I access it through code I would reference tblUsers.
There were a few potential problems, and conventions(lack thereof) that could have been causing problems, or by their nature were extremely prone to causing problems.
My main focus was to fix those poor areas, and then run it with full compile, fixing lines where it crashed.
My post 29 covers most of the areas I 'fixed'
I also replaced the connection code, rather than try to fix it.
Thus, I did not try to nail down what exactly was causing the error(s), I was just trying to fix it all.
aldryn05 probably has studied my code, and compared it to his, so he might be in a better position to describe what he thinks was causing the error(s)
Regards,
Rob
yeah, im still studying and comparing it until now.. im thinking on how did you know what really the problem, aside from the table name.. i am really not good in visual basic, i need to study more about vb and codes...