473,327 Members | 1,952 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Using tab/enter to move to a new line in continuous form

38
I'm trying to contol tab/enter so that when user presses it in a sub form, there's a msgbox asking him if he wants to move to another line or from the subform to the form itself.
I need to direct it to a new line and not the same existing one (I'm using the lostfocus even).

How do I do it please?
Thanks.
Nov 8 '07 #1
3 2424
ADezii
8,834 Expert 8TB
I'm trying to contol tab/enter so that when user presses it in a sub form, there's a msgbox asking him if he wants to move to another line or from the subform to the form itself.
I need to direct it to a new line and not the same existing one (I'm using the lostfocus even).

How do I do it please?
Thanks.
  1. Set the KeyPreview property of the Sub-Form to Yes.
  2. Place similar code in the KeyPress() Event of the Sub-Form as in:
    Expand|Select|Wrap|Line Numbers
    1. Private Sub Form_KeyPress(KeyAscii As Integer)
    2. Const conTabKey As Integer = 9
    3. Dim Msg As String, Response As Integer
    4.  
    5. Msg = "Move to Main Form?" & vbCrLf & vbCrLf
    6. Msg = Msg & "Yes to Move to the Main Form" & vbCrLf
    7. Msg = Msg & "No to Move to the Next Record in this Sub-Form"
    8.  
    9. If KeyAscii = conTabKey Then
    10.   Response = MsgBox(Msg, vbQuestion + vbYesNoCancel + vbDefaultButton1, "Your Title Here")
    11.     Select Case Response
    12.       Case vbYes
    13.         MsgBox "Moving to Main Form"
    14.       Case vbNo
    15.         MsgBox "Remaining in Sub-Form"
    16.       Case vbCancel
    17.         'do nothing
    18.     End Select
    19. End If
    20. End Sub
Nov 8 '07 #2
eyalco
38
Thanks very much for that - works like a charm.
Nov 9 '07 #3
ADezii
8,834 Expert 8TB
Thanks very much for that - works like a charm.
I'm glad it worked out for you but I do see a problem in that this kind of behaviour could be very annoying for the User. Does this logic need to be implemented for every Field in the Sub-Form?
Nov 9 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Ali Eghtebas | last post by:
Hi, I have 3 questions regarding the code below: 1) Why can't I trap the KEYDOWN while I can trap KEYUP? 2) Is it correct that I use Return True within the IF-Statement? (I've already read...
2
by: aaj | last post by:
Hi all I have a small but rather annoying problem with continuos forms, and am wondering if anyone can suggest a method of getting over it. The front end is Access 2002 with the BE being SQL...
6
by: Terry | last post by:
I have a form which is displayed in Datasheet View and would prefer it if, when entering data, I could use the keyboard as I would when entering data into a Datasheet. Is it possible when...
2
by: lemming | last post by:
I'd like to save the current record only with "enter" and noch with "shift-enter" (default). Has anyone an idea ? Thanks, Klaudia
4
by: Kathy | last post by:
What is the standard technique for handling the fields in the following scenario on a continuous form? Multiple Divisions. Each Division has multiple Buildings. Each Building has a Supervisor. ...
6
by: Prakash | last post by:
Hi !! In a Continuous Form with say 10 records, I'd like to have 1 button with an "UP" Arrow & another button with a "DOWN" arrow. By pressing either the Up or the Down Arrow, I'd like the user...
1
by: chfran | last post by:
I have a form (continuous) that show me data from a table (not a query). I can only modify and move between the data of the first record. I cannot move to the 2nd, 3rd, or 85th record, only the...
3
by: Simon Verona | last post by:
Sorry for the repost, but this group seems to be more "active" than the group that I posted my question, and it's probably as valid here as there! I have a usercontrol, which contains a textbox...
8
by: jmarcrum | last post by:
I have a table with about 100 records. The user has the ability to click a button on the main form that will open up a "move to the next year" form. A query displays all 100 records on the...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.