Home » excel » VBA Excel dataform not displaying the right input and fields

VBA Excel dataform not displaying the right input and fields

Posted by: admin May 14, 2020 Leave a comment

Questions:

I have the following VBA code, which should show a dataform from another hidden sheet.

Sub CoverageBssEntry()

   Application.ScreenUpdating = False
   Sheets("myhiddensheet").Select
   Range("myTable[#All]").Select
   ActiveSheet.ShowDataForm

End Sub

When I run this, the data form does not containt the labels and inputboxes of this table.

Any help is really appreciated, because it is driving me nuts! My only other option is to spend time to build custom made user forms, while this would do perfectly.

How to&Answers:

You cannot select a hidden sheet. And anyway the .Select statements are not necessary

Try

Sheets("myhiddensheet").ShowDataForm

Answer:

The fix is to use:

ActiveSheet.Cells(x,y).Select 

prior calling the .ShowDataForm, works like a jiffy!

Answer:

I think there are genuine constraints with the ShowDataForm command. It works fine if invoked outside of VBA while in a specific range. But once coded into VBA, it will only return the form for the first table in the referenced worksheet, even if a macro was recorded to perform that action.
I cannot tell why. Maybe because the showdataform event is tied to the worksheet and not to the table or list selected when it is called. Sorry guys. Maybe microsoft will improve this in the future.