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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
Staying in the textbox for new input
Thanks Al
I got it! Take care! -elli- |
Thread Tools | |
Display Modes | |
|
|
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 |