Forum Discussion

JonesyT's avatar
JonesyT
Copper Contributor
Jan 17, 2022
Solved

Cannot Extend table or database with Form Macro

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?

  • 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

     

4 Replies

    • JonesyT's avatar
      JonesyT
      Copper Contributor

      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

      • 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

         

Resources