From: Bob H on 4 Jun 2010 14:39 I am trying to create a login box for an Access 2007 database using some VB8 code I found: Private Sub CreateAcc_Click() Dim username As String username = Text23 If Text23 = "" Then MsgBox "Enter a Username !" Else If Text25 = "" Then MsgBox "Enter a Password !" Else Open app.Path & "\Accounts\Users\" + username + ".txt" For Output As #1 Print #1, Text23 Print #1, Text25 Close #1 End If End If End Sub It runs up to the line 'Open app.path etc, then get a runtime error 424, Object required. What would that be, and what should the correct syntax be for Open app.path Thanks
From: Ken Snell on 4 Jun 2010 15:15 Open CurrentProject.Path & "\Accounts\Users\" + username + ".txt" For Output As #1 -- Ken Snell http://www.accessmvp.com/KDSnell/ "Bob H" <bob(a)despammer.com> wrote in message news:Ac2dndAyF-_21ZTRnZ2dnUVZ7tqdnZ2d(a)giganews.com... >I am trying to create a login box for an Access 2007 database using some >VB8 code I found: > > Private Sub CreateAcc_Click() > Dim username As String > username = Text23 > If Text23 = "" Then > MsgBox "Enter a Username !" > Else > If Text25 = "" Then > MsgBox "Enter a Password !" > Else > Open app.Path & "\Accounts\Users\" + username + ".txt" For Output As > #1 > Print #1, Text23 > Print #1, Text25 > Close #1 > End If > End If > > End Sub > > It runs up to the line 'Open app.path etc, then get a runtime error 424, > Object required. > What would that be, and what should the correct syntax be for Open > app.path > > Thanks
From: Douglas J. Steele on 4 Jun 2010 15:21 There is no App object in Access. Private Sub CreateAcc_Click() Dim intFile As Integer Dim username As String username = Me!Text23 & vbNullString If Len(username) = 0 Then MsgBox "Enter a Username !" Else If Len(Me!Text25 & vbNullString) = 0 Then MsgBox "Enter a Password !" Else intFile = FreeFile() Open CurrentProject.Path & "\Accounts\Users\" & username & ".txt" For Output As #intFile Print #intFile, Me!Text23 Print #intFile, Me!Text25 Close #intFile End If End If End Sub -- 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(a)despammer.com> wrote in message news:Ac2dndAyF-_21ZTRnZ2dnUVZ7tqdnZ2d(a)giganews.com... >I am trying to create a login box for an Access 2007 database using some >VB8 code I found: > > Private Sub CreateAcc_Click() > Dim username As String > username = Text23 > If Text23 = "" Then > MsgBox "Enter a Username !" > Else > If Text25 = "" Then > MsgBox "Enter a Password !" > Else > Open app.Path & "\Accounts\Users\" + username + ".txt" For Output As > #1 > Print #1, Text23 > Print #1, Text25 > Close #1 > End If > End If > > End Sub > > It runs up to the line 'Open app.path etc, then get a runtime error 424, > Object required. > What would that be, and what should the correct syntax be for Open > app.path > > Thanks
From: Daniel Pineault on 4 Jun 2010 15:50 To pull the path of your currently open database you'd use: Application.CurrentProject.Path -- Hope this helps, Daniel Pineault http://www.cardaconsultants.com/ For Access Tips and Examples: http://www.devhut.net Please rate this post using the vote buttons if it was helpful. "Bob H" wrote: > I am trying to create a login box for an Access 2007 database using some > VB8 code I found: > > Private Sub CreateAcc_Click() > Dim username As String > username = Text23 > If Text23 = "" Then > MsgBox "Enter a Username !" > Else > If Text25 = "" Then > MsgBox "Enter a Password !" > Else > Open app.Path & "\Accounts\Users\" + username + ".txt" For Output As #1 > Print #1, Text23 > Print #1, Text25 > Close #1 > End If > End If > > End Sub > > It runs up to the line 'Open app.path etc, then get a runtime error 424, > Object required. > What would that be, and what should the correct syntax be for Open app.path > > Thanks > . >
From: Bob H on 4 Jun 2010 15:57 Thanks for the coding but now I get runtime error 2465 at the line: username = Me!Text23& vbNullString. Thanks On 04/06/2010 20:21, Douglas J. Steele wrote: > There is no App object in Access. > > Private Sub CreateAcc_Click() > Dim intFile As Integer > Dim username As String > > username = Me!Text23& vbNullString > If Len(username) = 0 Then > MsgBox "Enter a Username !" > Else > If Len(Me!Text25& vbNullString) = 0 Then > MsgBox "Enter a Password !" > Else > intFile = FreeFile() > Open CurrentProject.Path& "\Accounts\Users\"& username& ".txt" For > Output As #intFile > Print #intFile, Me!Text23 > Print #intFile, Me!Text25 > Close #intFile > End If > End If > > End Sub > >
|
Next
|
Last
Pages: 1 2 3 Prev: Forms or Tables Next: How to get Email address list from Outlook to Msaccess |