Even an error with this code I copied

I found a password login system for Access and copied it to aon click 
event on a form in Access 2007, but there is an error in the coding.

I have created a tblEmployees with the following fields:
IngEmpID
strEmpName
strEmpPassword
Then I put a unbound combo box on a form with the username and password 
fields. The combo box gets a list from strEmpName in the tblEmployees

I then copied the code given into the on click event of the cmd button:
  BUT there is a Compile error 'variable not defined' IngMyEmpID, as 
shown below

'Check to see if data is entered into the UserName combo box

     If IsNull(Me.cboEmployee) Or Me.cboEmployee = "" Then
       MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
         Me.cboEmployee.SetFocus
         Exit Sub
     End If

     'Check to see if data is entered into the password box

     If IsNull(Me.txtPassword) Or Me.txtPassword = "" Then
       MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
         Me.txtPassword.SetFocus
         Exit Sub
     End If

     'Check value of password in tblEmployees to see if this
     'matches value chosen in combo box

     If Me.txtPassword.Value = DLookup("strEmpPassword", "tblEmployees", _
             "[lngEmpID]=" & Me.cboEmployee.Value) Then

         lngMyEmpID = Me.cboEmployee.Value <
  BUT here there is a Compile error 'variable not defined' IngMyEmpID

         'Close logon form and open splash screen

         DoCmd.Close acForm, "frmLogon", acSaveNo
         DoCmd.OpenForm "frmSplash_Screen"

     Else
       MsgBox "Password Invalid. Please Try Again", vbOKOnly, _
             "Invalid Entry!"
         Me.txtPassword.SetFocus
     End If

     'If User Enters incorrect password 3 times database will shutdown

     intLogonAttempts = intLogonAttempts + 1
     If intLogonAttempts > 3 Then
       MsgBox "You do not have access to this database.Please contact 
admin.", _
                vbCritical, "Restricted Access!"
         Application.Quit
     End If

Thanks
0
Bob
6/6/2010 1:41:46 PM
access.forms 6864 articles. 2 followers. Follow

5 Replies
1860 Views

Similar Articles

[PageSpeed] 49

Have you declared lngMyEmpID in your code?

I.e. do you have the following statement anywhere?

Dim lngMyEmpID As Long

-- 
Doug Steele, Microsoft Access MVP
http://www.AccessMVP.com/djsteele
Co-author: "Access 2010 Solutions", published by Wiley
(no e-mails, please!)



"Bob H" <bob@despammer.com> wrote in message 
news:fYKdnV2s1M4GOJbRnZ2dnUVZ8jydnZ2d@giganews.com...
>I found a password login system for Access and copied it to aon click event 
>on a form in Access 2007, but there is an error in the coding.
>
> I have created a tblEmployees with the following fields:
> IngEmpID
> strEmpName
> strEmpPassword
> Then I put a unbound combo box on a form with the username and password 
> fields. The combo box gets a list from strEmpName in the tblEmployees
>
> I then copied the code given into the on click event of the cmd button:
>  BUT there is a Compile error 'variable not defined' IngMyEmpID, as shown 
> below
>
> 'Check to see if data is entered into the UserName combo box
>
>     If IsNull(Me.cboEmployee) Or Me.cboEmployee = "" Then
>       MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
>         Me.cboEmployee.SetFocus
>         Exit Sub
>     End If
>
>     'Check to see if data is entered into the password box
>
>     If IsNull(Me.txtPassword) Or Me.txtPassword = "" Then
>       MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
>         Me.txtPassword.SetFocus
>         Exit Sub
>     End If
>
>     'Check value of password in tblEmployees to see if this
>     'matches value chosen in combo box
>
>     If Me.txtPassword.Value = DLookup("strEmpPassword", "tblEmployees", _
>             "[lngEmpID]=" & Me.cboEmployee.Value) Then
>
>         lngMyEmpID = Me.cboEmployee.Value <
>  BUT here there is a Compile error 'variable not defined' IngMyEmpID
>
>         'Close logon form and open splash screen
>
>         DoCmd.Close acForm, "frmLogon", acSaveNo
>         DoCmd.OpenForm "frmSplash_Screen"
>
>     Else
>       MsgBox "Password Invalid. Please Try Again", vbOKOnly, _
>             "Invalid Entry!"
>         Me.txtPassword.SetFocus
>     End If
>
>     'If User Enters incorrect password 3 times database will shutdown
>
>     intLogonAttempts = intLogonAttempts + 1
>     If intLogonAttempts > 3 Then
>       MsgBox "You do not have access to this database.Please contact 
> admin.", _
>                vbCritical, "Restricted Access!"
>         Application.Quit
>     End If
>
> Thanks 

0
Douglas
6/6/2010 1:48:28 PM
On 06/06/2010 14:48, Douglas J. Steele wrote:
> Have you declared lngMyEmpID in your code?
>
> I.e. do you have the following statement anywhere?
>
> Dim lngMyEmpID As Long
>
I didn't actually, thanks.

But now I get another Runtime error '2471':
The expression you entered as a query paramter produced this error:
IngMyEmpID

And when I debug, this is highlighted:

If Me.txtPassword.Value = DLookup("strEmpPassword", "tblEmployees", _
             "lngMyEmpID=" & Me.cboEmployee.Value) Then

Thanks
0
Bob
6/6/2010 3:32:16 PM
On 06/06/2010 16:32, Bob H wrote:
> On 06/06/2010 14:48, Douglas J. Steele wrote:
>> Have you declared lngMyEmpID in your code?
>>
>> I.e. do you have the following statement anywhere?
>>
>> Dim lngMyEmpID As Long
>>

Apologies, I missed out the square brackets, but the error is still the 
same.

> I didn't actually, thanks.
>
> But now I get another Runtime error '2471':
> The expression you entered as a query paramter produced this error:
> IngMyEmpID
>
> And when I debug, this is highlighted:
>
> If Me.txtPassword.Value = DLookup("strEmpPassword", "tblEmployees", _
> "[lngMyEmpID=]" & Me.cboEmployee.Value) Then
>
> Thanks

0
Bob
6/6/2010 4:21:51 PM
On 06/06/2010 17:21, Bob H wrote:
> On 06/06/2010 16:32, Bob H wrote:
>> On 06/06/2010 14:48, Douglas J. Steele wrote:
>>> Have you declared lngMyEmpID in your code?
>>>
>>> I.e. do you have the following statement anywhere?
>>>
>>> Dim lngMyEmpID As Long
>>>
>
> Apologies, I missed out the square brackets, but the error is still the
> same.
>
>> I didn't actually, thanks.
>>
>> But now I get another Runtime error '2471':
>> The expression you entered as a query paramter produced this error:
>> IngMyEmpID
>>
>> And when I debug, this is highlighted:
>>
>> If Me.txtPassword.Value = DLookup("strEmpPassword", "tblEmployees", _
>> "[lngMyEmpID=]" & Me.cboEmployee.Value) Then
>>
>> Thanks
>

I have just found that I need to create a module and put this line in it

Public lngMyEmpID As Long

So when that is done how does it link to the form or button.

Thanks
0
Bob
6/6/2010 4:56:31 PM
If by creating a module and adding that line you're talking about putting 
the declaration into a second module (i.e. not the module in which the rest 
of your code is running), I'd suggest you solved the symptom but not the 
problem.

A large part of the problem trying to help you is that you're only giving 
little snippets of code without any context. How are you currently running 
the code? Your declaration should likely be in that procedure.

-- 
Doug Steele, Microsoft Access MVP
http://www.AccessMVP.com/DJSteele
Co-author: Access 2010 Solutions, published by Wiley
(no e-mails, please!)

"Bob H" <bob@despammer.com> wrote in message 
news:HaedneSFlOPdTpbRnZ2dnUVZ7rOdnZ2d@giganews.com...
> On 06/06/2010 17:21, Bob H wrote:
>> On 06/06/2010 16:32, Bob H wrote:
>>> On 06/06/2010 14:48, Douglas J. Steele wrote:
>>>> Have you declared lngMyEmpID in your code?
>>>>
>>>> I.e. do you have the following statement anywhere?
>>>>
>>>> Dim lngMyEmpID As Long
>>>>
>>
>> Apologies, I missed out the square brackets, but the error is still the
>> same.
>>
>>> I didn't actually, thanks.
>>>
>>> But now I get another Runtime error '2471':
>>> The expression you entered as a query paramter produced this error:
>>> IngMyEmpID
>>>
>>> And when I debug, this is highlighted:
>>>
>>> If Me.txtPassword.Value = DLookup("strEmpPassword", "tblEmployees", _
>>> "[lngMyEmpID=]" & Me.cboEmployee.Value) Then
>>>
>>> Thanks
>>
>
> I have just found that I need to create a module and put this line in it
>
> Public lngMyEmpID As Long
>
> So when that is done how does it link to the form or button.
>
> Thanks 


0
Douglas
6/7/2010 12:10:20 PM
Reply:

Similar Artilces:

roundup to next even number
I use this formula =SUM(A2*B2)/144 and need to roundup - but to the next even number so if calc returns 21.75 sb 22.00 or if 22.10 sb 24.00 I am brand new to this - any help would be appreciate -- Message posted from http://www.ExcelForum.com Hi one way: =ROUNDUP(A1/2,0)*2 or use =CEILING(A1,2) -- Regards Frank Kabel Frankfurt, Germany > I use this formula > =SUM(A2*B2)/144 > and need to roundup - but to the next even number > so if calc returns 21.75 sb 22.00 or if 22.10 sb 24.00 > I am brand new to this - any help would be appreciated > > > --- > Message...

BAR CODES
I am trying to program RMS to read my barcodes that print out from my meat scales. example: 0 200013 012100. i'm not sore about the first two digits but the "0001" is the item number. the "3" must me a check digit, the "01210" is the price,$12.10, and the last "0" must be a check digit. i have weighed up diferent weights and the only thing that stays the same in the "0 20001". i am looking for RMS to read the price off the barcode without having to put the price per pound in RMS. any suggestions? thank you K.PJ. You do have to give...

Deleting all even numbered rows?? Help
I have some data up to row 2200. Unfortunately, the data was capture with a glitch, to where all even numbered rows (2, 4, 6,.....2200 contain bogus data. I want to delete all even numbered rows in the spreadsheet, and hav the 1100 odd numbered rows shift up, so I have only 1100 rows of th real data on the spreadsheet -- Yel26 ----------------------------------------------------------------------- Yel268's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=1570 View this thread: http://www.excelforum.com/showthread.php?threadid=27234 Hi one way: - in a helper c...

Systems Manager Error
Hello, When I am in the ESM and try to access a public folder I get an error message: *************** The Object is no longer available. Press F5 to refresh the display, and then try again. ID no: 80040E19 Exchange System Manager *************** Its my understanding that the ESM relies on the Exadmin virtual directory (serviced by the default web site on IIS) for information regarding the public folders. Well, a colleague deleted the default web site and I'm sure that's why I am getting the error message. What I would like to know is how to re-establish the virtual direct...

Code to change a named range
Hello, I have a macro that runs and it ends up having to delete row 2 on 2 different sheets, which I do with..... which I am only showing a portion to make it short and easy. This causes a problem is it causes my named range to have a #REF where it used to say $B$2. With .Worksheets("BO Ref List") .Range("A1").PasteSpecial .Columns("A:B").RemoveDuplicates Columns:=Array(1, 2), Header:=xlYes .Range("A2:B2").Delete Shift:=xlUp With .Worksheets("FO Ref List") .Ra...

503 error on reply or foward
I'm using Outlook 2003 with XP pro, when I foward or reply to an e-mai I get the 503 error, I can create a new e-mail to the same address an it goes through, Any Ideas -- Tron2000Posted from http://www.pcreview.co.uk/ newsgroup acces ...

My If/Then doesn't fire even though "If" is true
I have a column of filepaths and a sub that steps through the table importing each file. It only works if: a: There is a filepath stored (and) b: if there is a file on the HD at that path. I have two if/then statments designed to trap these conditions If Me.LibItemFilePath = Null Then GoTo NextRecord 'If no filepath, skip If Len(Dir(Me.LibItemFilePath)) > 1 Then... 'If file exists then import The 1st line fails somehow, and the sub crashes on the 2nd line because the filepath is null, even though it should never get to the 2nd line if the filepath is nul...

Mirroring error 1418
I have a question about database mirroring. I am trying to test database mirroring . Somehow it is not working. I am getting 1418 error: SQL SERVER =96 Fix : Error: 1418 =96 Microsoft SQL Server =96 The server network address can not be reached or does not exist. Check the network address name and reissue the command I googled and tried all possible solutions that people suggested. Same error. Here are steps that I=92ve done: Servers(Principal, mirror and witness):SQL 2005 std edition sp3 Firewall is off for all servers. TCP/IP is enabled(from SQL server config....

Terminal Services Client toolbar/addin error
I can run the terminstall.cmd with no issue for each user and then open outlook where everything works. After I log off and log back on, I open outlook and get an error message 'error loading crm addin...' and the toolbars are greyed out. If I uninstall the client and reinstall everything works again until I log off/on. I've tried the IE trusted sites solution, msxml sp2 reinstall/repair solution, remove/add crmaddin solution, all with now success. Windows Server 2003 SP1 for all servers ...

Macro error after switching from Excel 2000 to Excel 2003
My company recently switched from Excel 2000 to Excel 2003 and now a macro I created does not work. It gives me the error 1004 and highlights the line of code where I set it up to open certain files in a folder. This macro has been working for 6 months without fail and only has problems opening the Excel files I created after the switch to 2003. Any help would be appreciated. Without any other info the only suggestion is to see if your sheets have different names. For example, a statement like: Sheets("Feb Sales").Cells(i, j+5) = k might cause a 1004 error if the new workb...

Error when trying to load program
I just purchase Outlook 2007. The box did not say anywhere that this was an upgrade but when I try to put the program on my computer I get the following message... Error 1311. Source file not found. E:\PA561401.CAB Anyone know what I need to do? -- Thanks, Catharine "Catharine" wrote in message news:37F53EC1-9B51-4AF4-9D82-3AD9E3621253@microsoft.com... >I just purchase Outlook 2007. The box did not say anywhere that this >was an > upgrade but when I try to put the program on my computer I get the > following > message... > > Error 1311. Source file not f...

Some errors occurred
In Windows Live Mail I am getting this message when opening: Some errors occurred while processing the requested tasks. Please review the list of errors below for more details. There are no details! 1 of 2 tasks have completed successfully. Besides having to close the message there are no other problems. OS: Windows Vista Home Premium SP2, 32 bit. Any corrective measures? Harry. "webster72n" <webster72n@gmail.com> a �crit dans le message de news:OV%23aJj68KHA.4600@TK2MSFTNGP02.phx.gbl... > In Windows Live Mail I am getting this message ...

SMTP Error 552
Our CEO uses his home AOL account a lot and lately when he emails from his AOL account to users within our company he has been getting a bounce back with a 552 error. I don't have a lot of specifics like if it is just one user or everyone. I know he has been email me and I have been getting them. He did say he tried last night and he got a bounce back and told me the user that he was trying to email. So I emailed that user this morning from a hotmail account and it got through the same user just fine. The 552 error is a storage limit error code but I don't have any limit's...

Were to begin ... is this even possible?
First, let me stress the question posed in the subject line ... is the following task even possible? I am not asking you guys to do this for me, but I do need some help! I am a dispatcher in a men's homeless shelter. I, along with three others, take in donations over the phone, for example, Joe Citizen @ 1234 Park Ave, My Town, OH, 34567 wants to donate a TV. I take this information down and late that night I make up what we call a ticket (currently all of this is done by hand ! ). This ticket also contains a map grid for the drivers to use the following day to locate ...

Email is deleted as unread and tagged with codes like E6
Email that I send to another PC that I control has started being deleted by the recipient PC without being read. I receive an email back from the recipient PC that the email was deleted without being read, and the subject line includes alphanumeric codes like E1 or E6. The mail is going to my inbox, not my junk folder on this PC. I've added the email addresses of both this PC and the recipient PC to the safe senders and safe recipients lists under the junk email options for both PCs. But I still get emails returned as unread. Is there something else that I can do to pr...

help with error
Task 'Microsoft Exchange Server' reported error (0x80070057) : 'Could not complete the operation. One or more parameter values are not valid.' I removed the outlook profile and recreated it to try and fix this problem but it did not work Please help ...

Distribute Columns Evenly
Hi, How do I? This is available in Word/Tables. Thank you -- Galen W. Sievert Hi AFAIK this option is not available in Excel -- Regards Frank Kabel Frankfurt, Germany "Galen W. Sievert, PC, MS Ed." <gsievert@matureservices.org> schrieb im Newsbeitrag news:u99K71BzEHA.3368@TK2MSFTNGP15.phx.gbl... > Hi, > How do I? This is available in Word/Tables. > Thank you > > -- > Galen W. Sievert > > Frank, Drats! Will have to do it the old fashion way. : ( Thanks for your reply! -- Galen W. Sievert "Frank Kabel" <frank.kabel@freenet.de&...

copy vanishes
I copy something from a workbook. Then I close that, open another workbook and try and paste but the stuff I copied has vanished. It's gone completely. I can't even paste it to word or anything. What happened? Vista Home Premium with office 2003 John This is an Excel behavior: the clipboard hold the copied stuff only while the ants are running around the selection. The clipboard is emptied if you do anything before pasting; that includes closing the source file. If you have the right Excel version, try using Office Clipboard rather than Windows Clipboard. In XL2003 find Office...

Error during upgrade
I get this message during upgrade to GP 9.0 from 7.5: Database: TWO Revenue Expense Deferrals: Product 1045 does not support upgrading from version 5.50.0 or prior. I dont see anything in the upgrade guide regarding this. Has anyone seen this error? Thanks much! It sounds like Revenue Expense Deferrals was installed while the install was at version 5.50 and the tables not upgrade from v5.50 when it was upgraded last. Since TWO is the lesson company can just ReAdd the sample company data from Dynamics Utilities. "chad.buser@ncsi.cc" wrote: > I get this message during ...

Error creating rules
Running Office 2000 suite, and Windows 2000. When trying to create a rule, outlook returns a meesage "Outlook.exe has encountered a fatal error." Any ideas on why this might happen? Thanks ...

Break Even Chart
Version: 2008 Operating System: Mac OS X 10.5 (Leopard) Processor: Intel Hi, <br><br>I am trying to learn how you create a break-even chart in Excel 2008. if anyone knows, i would greatly appreciate it if you could share your knowledge. <br><br>Sincerely, <br><br>Luis See here: http://www.jaxworks.com/Break-Even Chart.xls On 14/05/10 3:38 PM, in article 59bb8745.-1@webcrossing.JaKIaxP2ac0, "quipmaster@officeformac.com" <quipmaster@officeformac.com> wrote: > break-even chart -- The email below is my business email -...

event errors
Yes, i found one. Actually i found in my system event log this event id 5781. Also, our internet provider websitesource.com their office burned down this weekend and the DNS servers they had went down. How can i go around this so we can get back into outlook? Thanks for your help Dynamic registration or deletion of one or more DNS records associated with DNS domain 'seauxpierce.com.' failed. These records are used by other computers to locate this server as a domain controller (if the specified domain is an Active Directory domain) or as an LDAP server (if the specified dom...

Professional Tools Item Combiner Error
While attempting to combine two items I received the following error. Does anyone know the cause and how to correct? [Microsoft][ODBC SQL Server Driver][SQL Server]Violation of PRIMARY KEY constraint 'PKSOP60300'. Cannot insert duplicate key in object 'dbo.SOP60300' Hi Grieves This error means that youa re trying to create a record that already exists in the SOP60300 table within your SQL database. How comfortable are you with SQL scripting? If you are comfortable with SQL you can look in the table for the duplicate, ti will be one of the items your are trying to c...

Error in Outlook Synchronization
We have a user who has recently upgraded to UR 8 and when synchronizing, is receiving the following error on synchronizing CRM contacts and appointments to native Outlook Contacts and Appintments… Tracked records will be synchronized when the primary owner's Outlook Mailbox connects to Microsoft Dynamics CRM Interestingly enough, that user is the owner on these and is using the CRM Outlook client (online only). Has anyone seen this type of error before? Jack ...

Cell Reference Error
I realize when I reference a cell from another worksheet and tha worksheet does not exist, my SUM formula will not work and #REF appears. Is there a way for Excel to just count this lack of a worksheet as zer and allow the formula to work properly? Thanks, -Mik -- Message posted from http://www.ExcelForum.com Use 2 empty dummy sheets and sum them =SUM('first:last'!A20) then place all other sheets between them -- Regards, Peo Sjoblom (No private emails please, for everyone's benefit keep the discussion in the newsgroup/forum) "msherman83 >" <<msher...