Control record displayed in DataForm window

  • Thread starter Thread starter buczacz
  • Start date Start date
B

buczacz

The Excel data/form window facilitates entering data when the fields in
a record extend over more than the width of the display screen.

The VBA command, "dataform," opens the data form window, but it always
displays the top record on the sheet. Once it is open, you can then
manually scroll down to any record on the sheet. Is there any way to
control which record it displays on opening in Excel95 or Excel97 other
than reordering the sheet so that the record of interest is at the top
of the sheet?

Michael in Los Angeles
 
You could use send keys:

SendKeys "{DOWN " & ActiveCell.Row - 2 & "}"
Application.DisplayAlerts = False
ActiveSheet.ShowDataForm
Application.DisplayAlerts = True


This will start the dataform on the row with the activecell.

Replace activecell.row with the number of the row you want to start on.
 
I could not get the code you suggested to work.
I could not find a way to specify the number of down keystrokes.
Instead I used:

NDX = 1: Do While NDX < IDN: SendKeys "{down}": NDX = NDX + 1: Loop
Application.DisplayAlerts = False
ActiveSheet.ShowDataForm
Application.DisplayAlerts = True

Where IDN (Identification Number) is the number of the desired row to
which I want to scroll.

Could the problem be that I'm currently running it in Excel95?
Thanks for the hint.

Michael
 
Instead of using sendkeys within your loop, just figure out how many and pass
that number to it:

SendKeys "{DOWN " & NDX - 2 & "}"

But I'm not sure how you determined how many to come down, either.
 
Back
Top