A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » New Users
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Staying in the textbox for new input



 
 
Thread Tools Display Modes
  #1  
Old February 19th, 2006, 09:12 AM posted to microsoft.public.access.gettingstarted
external usenet poster
 
Posts: n/a
Default Staying in the textbox for new input

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


  #2  
Old February 19th, 2006, 03:39 PM posted to microsoft.public.access.gettingstarted
external usenet poster
 
Posts: n/a
Default Staying in the textbox for new input

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
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"

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...
--
hth
Al Camp
Candia Computer Consulting - Candia NH
http://home.comcast.net/~cccsolutions


"elli" wrote in message
...
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





  #3  
Old February 20th, 2006, 03:50 PM posted to microsoft.public.access.gettingstarted
external usenet poster
 
Posts: n/a
Default Staying in the textbox for new input

Thanks Al
I got it!
Take care!

-elli-


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Input Mask oddity - BUG? Rich1234 Using Forms 7 October 5th, 2005 11:07 PM
Query Where Clause Charles G via AccessMonster.com New Users 5 September 22nd, 2005 01:15 PM
Input Form vba help mdalzell General Discussion 0 April 8th, 2005 03:57 PM
Textbox, web browser control, and Unicode (got cutoff) Mark Johnson General Discussion 0 February 12th, 2005 01:08 AM
"Input" data sheet Kev General Discussion 0 November 3rd, 2004 12:15 PM


All times are GMT +1. The time now is 10:40 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.