Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

continuous form - using arrow keys move up,down or accoss 2

Status
Not open for further replies.

neemi

Programmer
May 14, 2002
519
GB
I have a contiuous form and want to give the user the ability to move either up, down, left or right in the grid system made up of the contious form fields...

Does anyone know how this is possible to do? as currently it moves left or right as the tab stop is set to true but even if the up or down key is pressed then it still moves left or right in the current record.

I am assuming that some coding with the key press even will be required on the objects but I have no idea on how to do this? Any help with the coding apreciated...

regards,
Neemi
 
How are ya neemi . . .

Detect up & down arrow keys in the forms [blue]On Key Down[/blue] event:
Code:
[blue]   Dim LastRec As Long
   
   LastRec = Me.Recordset.RecordCount
   
   If Shift = 0 Then
      If KeyCode = vbKeyUp Then
         If Me.CurrentRecord > 1 Then Me.Recordset.MovePrevious
         KeyCode = 0
      ElseIf KeyCode = vbKeyDown Then
         If Me.CurrentRecord < LastRec Then Me.Recordset.MoveNext
         KeyCode = 0
      End If
   End If[/blue]
[blue]Your Thoughts? . . .[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
I'm fine Aceman,

That is perfect and works great! Thanks for your help.

 
One more thing. on updating these individual feilds I run a requery which sets the current record as the first one on the recordsource. Any advice on running a requery but keeping focus to the feild that was updated in the record that was updated?
 
neemi . . .

You can save a record without having to requery with:
Code:
[blue]   docmd.RunCommand acCmdSaveRecord[/blue]
This is for the current record!

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
the reason why I am requerying is because when the user edits the field with a different number of hours some code runs which rights it to the main table. (table of dates is the main table and the recordsource is based on a maketable of a crosstab). and then the total hours is calculated which needs to be in the recordsource for the form, due to the fact that some conditional formatting is based on it. hence the requery.
It is quite complicated. so if you need me to explain in more detail please let me know.
 
neemi . . .

[blue]Roger That![/blue] [thumbsup2]

Here's the Idea:
Code:
[blue]   Dim hldID As Long, fldName As String
   
   hldID = Me![[purple][B][I]PrimaryKeyName[/I][/B][/purple]] [green]'to return to same record.[/green]
   fldName = Screen.ActiveControl.Name [green]'return to same field.[/green]
   
   Me.Requery
   
   Me.Recordset.FindFirst "[[purple][B][I]PrimaryKeyName[/I][/B][/purple]] = [red][b]'[/b][/red]" & hldID & "[red][b]'[/b][/red]"
   Me(fldName).SetFocus[/blue]
If the primarykey is numeric, remove the two single quotes in red ([red]'[/red]).

[blue]Your Thoughts? . . .[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
thats great cheers...
I kindoff done something like that but used recordset clone and bookmark etc..
whish way would be programatically better? the way you suggested or recordsetclone and bookmark? Any thoughts?
 
neemi . . .

Although the result is the same you generate more lines of code compared to the one!

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top