Built in Form Question

  • Thread starter Thread starter Jack Gillis
  • Start date Start date
J

Jack Gillis

Is there any way to have the form created by Data/Form come up showing
the info for the selected row in a Excel database? When I choose
Data/Form, it pops up showing the header for the database. I would like
it to show the info for the row that is selected. Perhaps a macro of
some sort?

Thank you.
 
Jack Gillis said:
Is there any way to have the form created by Data/Form come up showing
the info for the selected row in a Excel database? When I choose
Data/Form, it pops up showing the header for the database. I would like
it to show the info for the row that is selected. Perhaps a macro of
some sort?

AFAIK, the DataForm is not exposed to VBA, so a macro can only show the
Data form, not control its' focus..

I think you'd need to build a UserForm to do this.
 
You can use Sendkeys to get to the row you want.

Option Explicit
Sub testme()

'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???
 
YES! And thank you very much.

As far as unintended consequences you mentioned, it seems some of them
could be avoided by, in the macro, testing the application as well as
perhaps the Workbook and sheet name to make sure they are active. I
added a test for application that exits if it is not Excel.

Thank you again.

Jack
 
Back
Top