View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
GB GB is offline
external usenet poster
 
Posts: 230
Default Dataform - Forward/Backward Control

If you know the location of your first cell, then you can use a button, to
cause the activecell to change by one direction or another, simply by adding
one or subtracting one. But you have to test to see if you have reached the
end of your data set. I.e. if there is nothing and there should be, you must
decide if you want to loop back to the "beginning" or stop incrementing. If
incrementing in the other direction causes the "row" to be at or near say
zero, then must again decide.

Basically choose to select a new cell that meets the row/column criteria of
the new desired direction. Possible? Yeah.

"Dave Peterson" wrote:

Maybe something like:

Option Explicit
Sub testme()

SendKeys "%w"
Application.DisplayAlerts = False
ActiveSheet.ShowDataForm
Application.DisplayAlerts = True

End Sub

(The shortcut for a New record is alt-w (%w in Sendkeys syntax).)

or...

You can use Sendkeys to get to the row of the activecell you want.

Option Explicit
Sub testme2()

'tabs to the third field in that row
'SendKeys "{DOWN " & ActiveCell.Row - 2 & "}{TAB 3}"

'or just to the first field
SendKeys "{DOWN " & ActiveCell.Row - 2 & "}"
Application.DisplayAlerts = False
ActiveSheet.ShowDataForm
Application.DisplayAlerts = True

End Sub

Sendkeys is not a solution of choice for most things. Lots can go wrong--maybe
you won't be in excel when the macro runs, so something else will get the down's
and tabs???

Jim May wrote:

In Excel is there a way of entering controls on a form
to flip through the records of a table of data. I now
am loading the first record in the table into my form.
I just want to be able to <<using a control advance
to record 2,3,4,etc.. and 4,3,2,1
Can it be done? If so how..?
TIA,
Jim


--

Dave Peterson