DATA FORM

Seedubs

New Member
Joined
May 1, 2004
Messages
24
Hello all,

I have a spreadsheet with 2 sheets, on each sheet I have a set of data set up with a single row header so that it is recognised as a database, now I also have a macro to bring up the default DataForm to edit the data within the sheet (this macro is assigned to a button).

Now this works fine with one set of data on one sheet but on the other I am getting an error stating "Database or list range is not valid" when I try and run the DataForm.

Does excel restrict the use of DataForm to one set of data per workbook?

I am using Office 2000.

Any help or guidance would be greatly appreciated.

Chris
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Welcome to the Board!

What's your code? (Can you post it?)

You might be specifically referring to one sheet in the code.

Something like this will work for whatever sheet you're in:

<font face=Tahoma><SPAN style="color:#00007F">Sub</SPAN> DataForm()
    ActiveSheet.ShowDataForm
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>

hope that helps,

Smitty
 
Upvote 0
Thanks for the welcome, the code is as follows:

Sub Update1()
'
' Update1 Macro
' Macro recorded 01/05/2004 by CW Ltd
' Auto_Open Macro

Range("A2").Select
Worksheets("Update or Amend DVD listings").ShowDataForm
End Sub
Sub Update2()
'
' Update1 Macro
' Macro recorded 01/05/2004 by CW Ltd
' Auto_Open Macro

Range("A2").Select
Worksheets("Membership Details").ShowDataForm
End Sub

The two sheets are obviously "Update and Amend DVD Listings" and "Membership Details", it works for the update and amend DVD listings but for the other it is returning "Database or list range is not valid" and when I click on definition (in the debug) it states that the identifier under cursor is not recognised? (it is highlighting the second line Worksheets("Membership....) etc.

Many thanks

Chris
 
Upvote 0
Smitty's right if what you're doing is using seperate dataforms on the seperate sheets. You are limited to one dataform per sheet, not per workbook. (You can though, call the dataform of the activesheet and one from a different sheet all from the same sheet.)

If what you're trying to do is access sheet 1's dataform from sheet 2, then what you were doing should work. (ie. On sheet 2 your button's code should read): Sheets("Sheet1").ShowDataForm
This will allow you to use / edit the data in sheet 1 from sheet 2.

This any help?

Hey Smitty... (y)

Dan
 
Upvote 0
Thanks, but I am a little confused, I was under the impression that the dataform was produced automatically?

It takes the data from the database your cusor is on at the time of the request to open the dataform?

This dataform is named after the sheet it is opened on (that is why my sheets are named as such to make a more user friendly view when the form is opened).

So if you are allowed a Dataform per sheet, then surely this should work? Both sets of data are on different sheets?

I am accessing the dataform the only way possible - ie. going to the menu on the page and selecting Data and then form, this in itself would negate the possibility of me opening one dataform on another sheet?

I do not need to update the data from another sheet.

Sorry I am still confused as to why it will not work?

Many thanks for the efforts so far tho!!

Chris
 
Upvote 0
OK,
When you use the menu (Data > Form...) you are actually trying to create another dataform.

Your cursor doesn't need to be on or in the data range the dataform is using when you're calling up an existing one. (It only does when you're creating it.)

What I usually do is use a button from the Forms toolbar, (or any other form of macro activation method I suppose) to call up my dataforms. (Hence the code we've mentioned.) If you're only going to be calling up any dataform using the data that is on the activesheet, then you can just use:
Code:
Sub DataForm()
    ActiveSheet.ShowDataForm
End Sub
like Smitty said.

This help clear things up?
 
Upvote 0
Well, I have sorted this particular problem, for some reason it would only open one data form at a time, I could get it to run on one sheet and not the other, or vice versa, but the key seemed to be the line

myRng.Name = "database"


Even using ActiveSheet.showdataform did not work.

Whatever that did it sorted it

Many thanks for the efforts chaps!!

Chris



Working code is as follows:

Sub DataForm1()
'
' Update1 Macro
' Macro recorded 01/05/2004 by CW Ltd
' Auto_Open Macro
Dim myRng As Range
Set myRng = Worksheets("Update or Amend DVD listings").Range("a:j")
myRng.Name = "database"
Worksheets("Update or Amend DVD listings").ShowDataForm
End Sub

Sub DataForm2()
'
' Update1 Macro
' Macro recorded 01/05/2004 by CW Ltd
' Auto_Open Macro
Dim myRng As Range
Set myRng = Worksheets("Membership Details").Range("a:g")
myRng.Name = "database"
Worksheets("Membership Details").ShowDataForm

End Sub
 
Upvote 0

Forum statistics

Threads
1,215,824
Messages
6,127,109
Members
449,359
Latest member
michael2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top