How to move records with the down button in a tabular form (1 Viewer)

ct2013

Registered User.
Local time
Today, 03:19
Joined
Jun 6, 2013
Messages
87
Is it possible to move down records with the down button in a tabular form to the same field in the next record.

Ta
 

jdraw

Super Moderator
Staff member
Local time
Yesterday, 22:19
Joined
Jan 23, 2006
Messages
15,379
I'm sure it is, but it would involve some serious programming.
You may already know this, but for reference, a form is (generally) a means of displaying data from records in one or more tables. That data may have been manipulated by a query to select specific records, order those records, group those records etc.

So a lot of what you are asking depends on what data exactly is being displayed on the form, and how much has been done behind the scenes to manipulate the raw data.

Perhaps if you could describe your specific situation and what you want to accomplish in more detail and context, readers could offer more focused advice.

It's possible that by changing the criteria on the record source of your form you could get the desired result.

Good luck with your project.
 

ct2013

Registered User.
Local time
Today, 03:19
Joined
Jun 6, 2013
Messages
87
Thanks for your reply,

Basically i have a db which i made to keep track on students. i have an update query that places all the student in a table called 'term' which once updated they fill in the rest of the data on that term by the students name which was placed through the query.
I made a form which they open and displays all the student name under that term through a query and they can then place the data through a nice/easy to use form.

They find it a pain when they use the arrow that it goes through the fields of that record and then on to then on to that record which has 3 fields before they actually get to the one they want to fill in.

They want that on the down button it will just go down onto the next comment field in the next record without going through the other fields.


If anyone could help me i would be most grateful.

Many thanks once again
 

jdraw

Super Moderator
Staff member
Local time
Yesterday, 22:19
Joined
Jan 23, 2006
Messages
15,379
Perhaps a picture/jpg would help.

Who exactly are "they"?

We don't know what your form, or your query look like.

Perhaps you could tell us in plain English WHAT you are trying to do. So far you have told us how you have done something.
Can you post a copy of your database? Take out anything confidential/private. Does not have to be real data.
 

jdraw

Super Moderator
Staff member
Local time
Yesterday, 22:19
Joined
Jan 23, 2006
Messages
15,379
Please ignore this one
 
Last edited:

way2bord

Registered User.
Local time
Yesterday, 19:19
Joined
Feb 8, 2013
Messages
177
Please ignore this one
^ You can delete your post, instead of just editing it :D

Form Events:

KeyPreview = YES

OnKeyDown = ...

Code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = vbKeyDown Then
        DoCmd.GoToRecord acDataForm, Me.Form.Name, acNext
    End If
End Sub

You'll have to play with it to make it work how you want...but the basics are included.

edit: I'm assuming your "down button" is the down arrow key on the keyboard. If not - you need to specify what a "down button" is.
edit2: answer to your next question: "vbKeyUp" instead of KeyDown and "acPrevious" instead of "acNext"
 
Last edited:

Mihail

Registered User.
Local time
Today, 05:19
Joined
Jan 22, 2011
Messages
2,373
Or you can set the Tab Stop property to No for all controls, except that one you are interesting in.
 

jdraw

Super Moderator
Staff member
Local time
Yesterday, 22:19
Joined
Jan 23, 2006
Messages
15,379
way2bord,
I was sure there was a delete option, but I looked and couldn't find one -- so practicality took over --delete the text.

Also, I know I should be getting emails regarding posts, but I'm not and haven't been for over a month -- you got an answer for that one?
 

way2bord

Registered User.
Local time
Yesterday, 19:19
Joined
Feb 8, 2013
Messages
177
way2bord,
I was sure there was a delete option, but I looked and couldn't find one -- so practicality took over --delete the text.

Also, I know I should be getting emails regarding posts, but I'm not and haven't been for over a month -- you got an answer for that one?

User CP > Edit Options (left hand menu bar) > Messaging & Notification > Default Thread Subscription Mode > "Instant Email Notification"

You probably also need to Accept Emails from Admin and confirm e-mail is correctly listed.

If all these check out -- Notify server admin. :confused:
 

missinglinq

AWF VIP
Local time
Yesterday, 22:19
Joined
Jun 20, 2003
Messages
6,423
...You'll have to play with it to make it work how you want...

Not much playing, just add one line:

Screen.PreviousControl.SetFocus

But to stop this behavior after reaching the last Record in the Recordset, i.e. to keep the <Down Arrow> from reverting back to its default behavior, and confusing the user, you can check to see if the Record is the last Record before firing your code, and not doing so if you're on the last Record; you can also inform the user that they are on the last Record with a Messagebox.

So, to extend way2bord's suggestion:
Code:
Private Sub Form_Load()
 Me.KeyPreview = True
End Sub

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
   
 If Me.CurrentRecord <> Me.RecordsetClone.RecordCount Then
 
  If KeyCode = vbKeyDown Then
    DoCmd.GoToRecord acDataForm, Me.Form.Name, acNext
    Screen.PreviousControl.SetFocus
  End If
 
 Else
  
  MsgBox "You Are On the Last Record!"
  KeyCode = 0
  
 End If

End Sub

Or, if you want to navigate both Up and Down with the appropriate Arrows:

Code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
  
  Select Case KeyCode
  
   Case vbKeyDown
	
	If CurrentRecord <> RecordsetClone.RecordCount Then
	  DoCmd.GoToRecord , , acNext
          Screen.PreviousControl.SetFocus
	Else
	  Msgbox “You Are On the Last Record!”
	End If
	
   KeyCode = 0
   
   Case vbKeyUp
	
	If CurrentRecord <> 1 Then
	  DoCmd.GoToRecord , , acPrevious
          Screen.PreviousControl.SetFocus
	Else
 	  Msgbox “You Are On the First Record!”
	End If
	
	KeyCode = 0

 End Select

End Sub

Of course, you could simply change the Form from a Tabular (Continuous) Form, to a Datasheet View; this kind of behavior is standard on a Datasheet View Form!

Linq ;0)>
 
Last edited:

ct2013

Registered User.
Local time
Today, 03:19
Joined
Jun 6, 2013
Messages
87
Thank you very much for your replies.

i am trying this code, My form is called "Input data query art" and the field i want to use to make the script for is called "artcomments".

This gets an error!!!

******************

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)

If Me.CurrentRecord <> Me.RecordsetClone.RecordCount Then

If KeyCode = vbKeyDown Then
DoCmd.GoToRecord acDataForm, Me.Input Data Query Art.artcomments, acNext
Screen.PreviousControl.SetFocus
End If

Else

MsgBox "You Are On the Last Record!"
KeyCode = 0

End If

End Sub

******************

Please help me.

I have put a copy of the simple roar data if you want to check it out to get it working.

Many thanks
:banghead::eek::banghead:
 

Attachments

  • Database2.zip
    674.7 KB · Views: 70

missinglinq

AWF VIP
Local time
Yesterday, 22:19
Joined
Jun 20, 2003
Messages
6,423
You need to replace

Me.Input Data Query Art.artcomments

with the exact code you were given

Me.Form.Name

so you end up with

Code:
DoCmd.GoToRecord acDataForm, [COLOR="Red"]Me.Form.Name[/COLOR], acNext
You do not substitute anything for the Me.Form.Name!

BTW, the field you want doesn't matter; when you hit the <Down Arrow> you will move to the same field in the next Record, regardless of which field that was.

If you're on Field1 and hit <Down> you'll be on Field1 in the next record.

If you're on Field2 and hit <Down> you'll be on Field2 in the next record.

And so forth!

Linq ;0)>
 
Last edited:

Users who are viewing this thread

Top Bottom