Error 3315 (1 Viewer)

CJ_London

Super Moderator
Staff member
Local time
Today, 08:55
Joined
Feb 19, 2013
Messages
16,553
refer back to post #2 - one bit of your code does not assign a value to GUserName per gemma's second point
 

db-noob

Member
Local time
Today, 02:55
Joined
Oct 16, 2020
Messages
47
refer back to post #2 - one bit of your code does not assign a value to GUserName per gemma's second point
I'm confused. I thought GUserName = rst.Fields("UserName").Value did the job. If it's not, how do I change it (or add) so it does?
 

CJ_London

Super Moderator
Staff member
Local time
Today, 08:55
Joined
Feb 19, 2013
Messages
16,553
so look at post #5 - where are you assigning a value to GUserName if rst.eof is true? i.e. a user is not found. The main form still opens

Have you tried logging in where a username or password is incorrect? what happens?
 

db-noob

Member
Local time
Today, 02:55
Joined
Oct 16, 2020
Messages
47
so look at post #5 - where are you assigning a value to GUserName if rst.eof is true? i.e. a user is not found. The main form still opens

Have you tried logging in where a username or password is incorrect? what happens?
Oh darn.

I went back to my login form code and changed it to:

Code:
  strSQL = "SELECT UserName, Password FROM tbl_login WHERE UserName = """ & Me.txt_username.Value & """ AND Password = """ & Me.txt_password.Value & """"
 
  Set db = CurrentDb
  Set rst = db.OpenRecordset(strSQL)
  If rst.EOF Then
    'MsgBox prompt:="Incorrect username/password. Try again.", buttons:=vbCritical, Title:="Login Error" --- commented out 10/13/2020
    MsgBox prompt:="Incorrect username/password. Try again.", buttons:=vbCritical, Title:="Login Error" & "strSQL = " & strSQL 'added 10/13/2020
    Me.txt_username.SetFocus
    Exit Sub 'Added 1/13/2021 TESTING
  Else


I added the Exit Sub below where it sets focus on username. Then did this to test it:
Screenshot 2021-01-15 162946.jpg

Screenshot 2021-01-15 163429.jpg


I've noticed that some of my forms don't even have Option Compare Database. Should I put that and include Option Explicit?
 

db-noob

Member
Local time
Today, 02:55
Joined
Oct 16, 2020
Messages
47
definitely


teach you to read replies more carefully. That's a week of your life you won't get back ;)

Okay. Went back to all of my forms to include Option Compare Database and Option Explicit. Ran the Compile and nothing came up, which is suspicious. I'll deploy these changes and see if this error comes back on Monday.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 08:55
Joined
Feb 19, 2013
Messages
16,553
nothing came up, which is suspicious.
not necessarily. Doesn't mean you have handled all errors such as your gUserName problem. It does mean you can now create a .accde if you wanted which stops users from messing with forms and code.
 

db-noob

Member
Local time
Today, 02:55
Joined
Oct 16, 2020
Messages
47
not necessarily. Doesn't mean you have handled all errors such as your gUserName problem. It does mean you can now create a .accde if you wanted which stops users from messing with forms and code.
No GUsername problems so far.

.accde if you wanted which stops users from messing with forms and code

Ooh. I've seen that option during the File > Save As bit. Does an .accde stop users from creating/editing objects: forms, tables, queries, reports, macros, modules, etc?
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 08:55
Joined
Sep 12, 2006
Messages
15,614
users can still change tables and queries, but not other objects. It can be useful for them to be able to change queries at times, to be honest
 

CJ_London

Super Moderator
Staff member
Local time
Today, 08:55
Joined
Feb 19, 2013
Messages
16,553
if the tables are in a back end and the backend is password protected, users cannot change a table design (although someone who knows what they are doing can easily find the password), All they can do is delete the linked table in the front end. Any app that you are supporting (i.e. there is at least one other user) should be split as a matter of course as it makes it much easier to undertake maintenance.
 

db-noob

Member
Local time
Today, 02:55
Joined
Oct 16, 2020
Messages
47
if the tables are in a back end and the backend is password protected, users cannot change a table design (although someone who knows what they are doing can easily find the password), All they can do is delete the linked table in the front end. Any app that you are supporting (i.e. there is at least one other user) should be split as a matter of course as it makes it much easier to undertake maintenance.
Yes, the tables are stored on a password protected BE stored on a shared server. A max of 4 users (including myself) downloads a fresh copy of the FE onto their hard drive, by means of a batch file, every time they open the db.

@gemma-the-husky
users can still change tables and queries, but not other objects. It can be useful for them to be able to change queries at times, to be honest
As far as I know, no one other than me creates queries.
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 08:55
Joined
Sep 12, 2006
Messages
15,614
As far as I know, no one other than me creates queries.

its not that. If a user wants a one off "special", or finds a minor issue, it's possible to solve it sometimes by getting them to change an existing query under supervision, or adding a new query using the SQL statement, which avoids the delay in creating, testing and releasing a new version just for that change.
 

db-noob

Member
Local time
Today, 02:55
Joined
Oct 16, 2020
Messages
47
its not that. If a user wants a one off "special", or finds a minor issue, it's possible to solve it sometimes by getting them to change an existing query under supervision, or adding a new query using the SQL statement, which avoids the delay in creating, testing and releasing a new version just for that change.
Ah gotcha.
 

db-noob

Member
Local time
Today, 02:55
Joined
Oct 16, 2020
Messages
47
The error hasn't popped up in the last few days. Not to say that it's fixed or anything. Just not sure whether to leave this open or not.
 

Users who are viewing this thread

Top Bottom