View Single Post
  #14  
Old June 6th, 2010, 02:49 PM posted to microsoft.public.access.forms
Douglas J. Steele[_3_]
external usenet poster
 
Posts: 3,143
Default this code doesn't work fully

You've still got the #2 everywhere in your code! That should be #intFile.

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



"Bob H" wrote in message
...
On 05/06/2010 20:44, Douglas J. Steele wrote:
Hold on, my one answer was inaccurate! If all you're doing on the second
command button is reading the data from the file, open it for Input, not
Output!

Open "C:\Accounts\Users\" & username & ".txt" For Input As #intFile

You'd use

Open "C:\Accounts\Users\" & username & ".txt" For Output Shared As
#intFile

if you were doing both reads and writes in the same routine.



Ok, this is the code I am using to login to an account, using account
creation files.
Basically I want Access 2007 to read a previously created file, which has
the username and password in it. Once it has been read, then access is
granted to the whatever.

Private Sub cmdLogin_Click()
Dim openfile As String
Dim datafile As String
Dim intFile As Integer
openfile = Text1
datafile = Text2

If Text1 = "" Then
MsgBox "Please Enter a Username"
Else
If Text2 = "" Then
MsgBox " Please Enter a password"
Else
intFile = FreeFile()
Open "C:\Accounts\Users\" & Text1 & ".txt" For Input As #intFile

Input #2, openfile I am getting a runtime error here as before

If Text1 = openfile Then
Input #2, datafile
If Text2 = datafile Then
MsgBox "Granted Access"
Else
MsgBox "Denied Access"
End If
End If
Close #2
End If
End If
End Sub

I know there is something wrong with it at that line but I don't know what
else to change it to.

Thanks