SOLVED

Cannot Extend table or database with Form Macro

Occasional Contributor

Hi,

I wonder if someone can help me again.

 

I have a worksheet with a hidden data sheet. 

On one sheet there is a button that has an assigned macro to do the following:

- Unhide the data sheet

- open a form

- allow the user to enter new details

- once closed, hide the data sheet and return to initial sheet.

 

When I do this manually, (and when recording a macro doing this), I have no issues. However when ran as a macro, the form appears but upon trying to enter data i get the error message "Cannot Extend table or database"

 

VBA looks like this:

Sub AddDriverForm()
'
' AddDriverForm Macro
'

'
Sheets("AM Report").Select
Sheets("Driver Data").Visible = True
Sheets("Driver Data").Select
Application.Goto Reference:="Driverdata"
ActiveSheet.ShowDataForm
Sheets("Driver Data").Select
ActiveWindow.SelectedSheets.Visible = False
End Sub

 

 

 

Am i missing something obvious?

4 Replies

@JonesyT 

I didn't get an error in a quick test. Could you attach a small sample workbook demonstrating the problem?

Hi Hans,
Here is the link to the workbook i am working on with the data removed.

The sheets in question are AM Report and the Driver Data sheet.
Thank you so much for the assistance.
https://1drv.ms/x/s!AjkmikH6M6FfgaEStXsEuuu7uy1Qdg?e=2QfC0l
Tom

best response confirmed by JonesyT (Occasional Contributor)
Solution

@JonesyT 

Thanks! The Data Form is rather primitive. It expects the table to begin in row 1. If you delete the current row 1, the code should work. You don't even need to unhide the sheet: you can use

Sub AddDriverForm()
    Sheets("Driver Data").ShowDataForm
End Sub

 

Thank you Hans!!! I really appreciate it!!