Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / New Users / February 2006

Tip: Looking for answers? Try searching our database.

Staying in the textbox for new input

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
elli - 19 Feb 2006 09:12 GMT
Hi! (Again:))...
Thank U all for yesterday's help!
Today towards new challanges...
I created a form to ask username and password.
And even managed to make it to work..
Some little fixation still needed and this is where I need Your help. Now
when user puts wrong username there's a message-box saying: User not found
and so on  (in finnish though) and the wrong username is cleared from the
textbox. Then the So far so good...
Then the application jumps to the password section, insted of staying in the
Kayttaja- textbox to let the user correct his/hers typing.... So what is the
piece of code that my code needs to stay there?

Thanks -elli the menace-

Private Sub Kayttaja_LostFocus()
Dim con As Object
   Dim rs As Object
   Dim s_sql As String
   Set con = Application.CurrentProject.Connection
   Set rs = CreateObject("ADODB.Recordset")
   s_sql = "select * from Users where Kayttaja='" & Trim(Kayttaja) & "'"
   rs.Open s_sql, con, 1
   If rs.EOF = True Then
   MsgBox "Käyttäjää ei löydy"
   Me.Kayttaja = ""
   Else
   apupw = rs!Salasana
   End If
End Sub
Al Camp - 19 Feb 2006 15:39 GMT
Elli,
  The best place for your code would be in the BeforeUpdate event of your
password text control.
  The BeforeUpdate event is a "cancelable" procedure, so...
  (Assuming Kayttaja is a bound field)

  Private Sub Kayttaja_BEFOREUPDATE(Cancel as Integer)   ' <****
> Dim con As Object
>    Dim rs As Object
[quoted text clipped - 5 lines]
>    If rs.EOF = True Then
>        MsgBox "Käyttäjää ei löydy"
         Cancel = True
'<*****
         Me.Kayttaja.Undo
'<*****
>    Else
>    apupw = rs!Salasana
>    End If
> End Sub

If Kayttaja is an unbound field, just do the Cancel = True.  The original
text
entry will remain, but be highlighted for over typing.  That should be OK...
Signature

hth
Al Camp
Candia Computer Consulting - Candia NH
http://home.comcast.net/~cccsolutions

> Hi! (Again:))...
> Thank U all for yesterday's help!
[quoted text clipped - 26 lines]
>    End If
> End Sub
elli - 20 Feb 2006 15:50 GMT
Thanks Al
I got it!
Take care!

-elli-
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.