PC Review


Reply
Thread Tools Rate Thread

Auto open Data Form

 
 
ypukpete
Guest
Posts: n/a
 
      25th Mar 2009
I wish to auto open excel's built in dataform and if possible hide the
worksheet it relates to.
I have tried Dave Peterson's...
Sub Auto_Open
Set wks = Worksheets("Sheet2")
With wks
Application.DisplayAlerts = False
..ShowDataForm
Application.DisplayAlerts = True
End With
End Sub

But had no success, the code breaks at .ShowDataForm
I would like to show the dataform and hide worksheet2 if possible
I am using excel 2000
Thanks in advance for your help with this.

--
ypukpete
 
Reply With Quote
 
 
 
 
FSt1
Guest
Posts: n/a
 
      25th Mar 2009
do you have data on sheet2? if not the macro will crash at .showdataform.

regards
FSt1

"ypukpete" wrote:

> I wish to auto open excel's built in dataform and if possible hide the
> worksheet it relates to.
> I have tried Dave Peterson's...
> Sub Auto_Open
> Set wks = Worksheets("Sheet2")
> With wks
> Application.DisplayAlerts = False
> .ShowDataForm
> Application.DisplayAlerts = True
> End With
> End Sub
>
> But had no success, the code breaks at .ShowDataForm
> I would like to show the dataform and hide worksheet2 if possible
> I am using excel 2000
> Thanks in advance for your help with this.
>
> --
> ypukpete

 
Reply With Quote
 
ypukpete
Guest
Posts: n/a
 
      25th Mar 2009
Yes..the data I am using is in Sheet2 and the dataform is operating OK
--
ypukpete


"FSt1" wrote:

> do you have data on sheet2? if not the macro will crash at .showdataform.
>
> regards
> FSt1
>
> "ypukpete" wrote:
>
> > I wish to auto open excel's built in dataform and if possible hide the
> > worksheet it relates to.
> > I have tried Dave Peterson's...
> > Sub Auto_Open
> > Set wks = Worksheets("Sheet2")
> > With wks
> > Application.DisplayAlerts = False
> > .ShowDataForm
> > Application.DisplayAlerts = True
> > End With
> > End Sub
> >
> > But had no success, the code breaks at .ShowDataForm
> > I would like to show the dataform and hide worksheet2 if possible
> > I am using excel 2000
> > Thanks in advance for your help with this.
> >
> > --
> > ypukpete

 
Reply With Quote
 
john
Guest
Posts: n/a
 
      25th Mar 2009
Give this approach a try:

Sub Auto_Open()

Set wks = Worksheets("Sheet2")

Application.DisplayAlerts = False

On Error GoTo myerror
With wks

.Activate
.Range("A1").Select

.ShowDataForm

End With

myerror:
If Err > 0 Then
MsgBox (Error(Err))
Err.Clear
End If

Application.DisplayAlerts = True

End Sub

--
jb


"ypukpete" wrote:

> I wish to auto open excel's built in dataform and if possible hide the
> worksheet it relates to.
> I have tried Dave Peterson's...
> Sub Auto_Open
> Set wks = Worksheets("Sheet2")
> With wks
> Application.DisplayAlerts = False
> .ShowDataForm
> Application.DisplayAlerts = True
> End With
> End Sub
>
> But had no success, the code breaks at .ShowDataForm
> I would like to show the dataform and hide worksheet2 if possible
> I am using excel 2000
> Thanks in advance for your help with this.
>
> --
> ypukpete

 
Reply With Quote
 
ypukpete
Guest
Posts: n/a
 
      25th Mar 2009
Hi John
Tried your approach
get MsgBox saying....Method"ShowDataForm"of object_Worksheet Failed

--
ypukpete


"john" wrote:

> Give this approach a try:
>
> Sub Auto_Open()
>
> Set wks = Worksheets("Sheet2")
>
> Application.DisplayAlerts = False
>
> On Error GoTo myerror
> With wks
>
> .Activate
> .Range("A1").Select
>
> .ShowDataForm
>
> End With
>
> myerror:
> If Err > 0 Then
> MsgBox (Error(Err))
> Err.Clear
> End If
>
> Application.DisplayAlerts = True
>
> End Sub
>
> --
> jb
>
>
> "ypukpete" wrote:
>
> > I wish to auto open excel's built in dataform and if possible hide the
> > worksheet it relates to.
> > I have tried Dave Peterson's...
> > Sub Auto_Open
> > Set wks = Worksheets("Sheet2")
> > With wks
> > Application.DisplayAlerts = False
> > .ShowDataForm
> > Application.DisplayAlerts = True
> > End With
> > End Sub
> >
> > But had no success, the code breaks at .ShowDataForm
> > I would like to show the dataform and hide worksheet2 if possible
> > I am using excel 2000
> > Thanks in advance for your help with this.
> >
> > --
> > ypukpete

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      25th Mar 2009
I bet your data isn't where excel expects it to be.

Here's an article that explains how the problem occurs in VBA (with solution)
http://support.microsoft.com/default...;en-us;q110462
XL: ShowDataForm Method Fails If Data Can't Be Found

ypukpete wrote:
>
> I wish to auto open excel's built in dataform and if possible hide the
> worksheet it relates to.
> I have tried Dave Peterson's...
> Sub Auto_Open
> Set wks = Worksheets("Sheet2")
> With wks
> Application.DisplayAlerts = False
> .ShowDataForm
> Application.DisplayAlerts = True
> End With
> End Sub
>
> But had no success, the code breaks at .ShowDataForm
> I would like to show the dataform and hide worksheet2 if possible
> I am using excel 2000
> Thanks in advance for your help with this.
>
> --
> ypukpete


--

Dave Peterson
 
Reply With Quote
 
ypukpete
Guest
Posts: n/a
 
      25th Mar 2009
Thanks John
Your code led to the error report
Thanks Dave, you won your bet, moved the sheet to A1:B2
both methods work fine now.
Can I now ask how to hide Sheet2 with the DataForm displayed?
--
ypukpete


"Dave Peterson" wrote:

> I bet your data isn't where excel expects it to be.
>
> Here's an article that explains how the problem occurs in VBA (with solution)
> http://support.microsoft.com/default...;en-us;q110462
> XL: ShowDataForm Method Fails If Data Can't Be Found
>
> ypukpete wrote:
> >
> > I wish to auto open excel's built in dataform and if possible hide the
> > worksheet it relates to.
> > I have tried Dave Peterson's...
> > Sub Auto_Open
> > Set wks = Worksheets("Sheet2")
> > With wks
> > Application.DisplayAlerts = False
> > .ShowDataForm
> > Application.DisplayAlerts = True
> > End With
> > End Sub
> >
> > But had no success, the code breaks at .ShowDataForm
> > I would like to show the dataform and hide worksheet2 if possible
> > I am using excel 2000
> > Thanks in advance for your help with this.
> >
> > --
> > ypukpete

>
> --
>
> Dave Peterson
>

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      25th Mar 2009
Just hide it manually (when you're wearing your developer's hat).

Your code doesn't need to have the worksheet visible to work.

If you only have that single sheet in the workbook, I'd add another worksheet
(named Instructions) with a button from the Forms toolbar that runs that macro.

And add some instructions for those hard to fill out fields.



ypukpete wrote:
>
> Thanks John
> Your code led to the error report
> Thanks Dave, you won your bet, moved the sheet to A1:B2
> both methods work fine now.
> Can I now ask how to hide Sheet2 with the DataForm displayed?
> --
> ypukpete
>
> "Dave Peterson" wrote:
>
> > I bet your data isn't where excel expects it to be.
> >
> > Here's an article that explains how the problem occurs in VBA (with solution)
> > http://support.microsoft.com/default...;en-us;q110462
> > XL: ShowDataForm Method Fails If Data Can't Be Found
> >
> > ypukpete wrote:
> > >
> > > I wish to auto open excel's built in dataform and if possible hide the
> > > worksheet it relates to.
> > > I have tried Dave Peterson's...
> > > Sub Auto_Open
> > > Set wks = Worksheets("Sheet2")
> > > With wks
> > > Application.DisplayAlerts = False
> > > .ShowDataForm
> > > Application.DisplayAlerts = True
> > > End With
> > > End Sub
> > >
> > > But had no success, the code breaks at .ShowDataForm
> > > I would like to show the dataform and hide worksheet2 if possible
> > > I am using excel 2000
> > > Thanks in advance for your help with this.
> > >
> > > --
> > > ypukpete

> >
> > --
> >
> > Dave Peterson
> >


--

Dave Peterson
 
Reply With Quote
 
ypukpete
Guest
Posts: n/a
 
      26th Mar 2009
Thanks for advice
must wear my developers hat more often
might make life easier.
Regards
--
ypukpete


"Dave Peterson" wrote:

> Just hide it manually (when you're wearing your developer's hat).
>
> Your code doesn't need to have the worksheet visible to work.
>
> If you only have that single sheet in the workbook, I'd add another worksheet
> (named Instructions) with a button from the Forms toolbar that runs that macro.
>
> And add some instructions for those hard to fill out fields.
>
>
>
> ypukpete wrote:
> >
> > Thanks John
> > Your code led to the error report
> > Thanks Dave, you won your bet, moved the sheet to A1:B2
> > both methods work fine now.
> > Can I now ask how to hide Sheet2 with the DataForm displayed?
> > --
> > ypukpete
> >
> > "Dave Peterson" wrote:
> >
> > > I bet your data isn't where excel expects it to be.
> > >
> > > Here's an article that explains how the problem occurs in VBA (with solution)
> > > http://support.microsoft.com/default...;en-us;q110462
> > > XL: ShowDataForm Method Fails If Data Can't Be Found
> > >
> > > ypukpete wrote:
> > > >
> > > > I wish to auto open excel's built in dataform and if possible hide the
> > > > worksheet it relates to.
> > > > I have tried Dave Peterson's...
> > > > Sub Auto_Open
> > > > Set wks = Worksheets("Sheet2")
> > > > With wks
> > > > Application.DisplayAlerts = False
> > > > .ShowDataForm
> > > > Application.DisplayAlerts = True
> > > > End With
> > > > End Sub
> > > >
> > > > But had no success, the code breaks at .ShowDataForm
> > > > I would like to show the dataform and hide worksheet2 if possible
> > > > I am using excel 2000
> > > > Thanks in advance for your help with this.
> > > >
> > > > --
> > > > ypukpete
> > >
> > > --
> > >
> > > Dave Peterson
> > >

>
> --
>
> Dave Peterson
>

 
Reply With Quote
 
john
Guest
Posts: n/a
 
      26th Mar 2009
sorry did not respond to your questions but I have been having problems
accessing this site although Dave appears to have solved your problem.

You can amend the code I posted to hide the sheet as follows:


Sub Auto_Open()

Set wks = Worksheets("Sheet2")

Application.DisplayAlerts = False

On Error GoTo myerror
With wks

.Activate
.Range("A1").Select
.Visible = False
.ShowDataForm

End With

myerror:
If Err > 0 Then
MsgBox (Error(Err))
Err.Clear
End If

Application.DisplayAlerts = True

End Sub
--
jb


"ypukpete" wrote:

> Thanks for advice
> must wear my developers hat more often
> might make life easier.
> Regards
> --
> ypukpete
>
>
> "Dave Peterson" wrote:
>
> > Just hide it manually (when you're wearing your developer's hat).
> >
> > Your code doesn't need to have the worksheet visible to work.
> >
> > If you only have that single sheet in the workbook, I'd add another worksheet
> > (named Instructions) with a button from the Forms toolbar that runs that macro.
> >
> > And add some instructions for those hard to fill out fields.
> >
> >
> >
> > ypukpete wrote:
> > >
> > > Thanks John
> > > Your code led to the error report
> > > Thanks Dave, you won your bet, moved the sheet to A1:B2
> > > both methods work fine now.
> > > Can I now ask how to hide Sheet2 with the DataForm displayed?
> > > --
> > > ypukpete
> > >
> > > "Dave Peterson" wrote:
> > >
> > > > I bet your data isn't where excel expects it to be.
> > > >
> > > > Here's an article that explains how the problem occurs in VBA (with solution)
> > > > http://support.microsoft.com/default...;en-us;q110462
> > > > XL: ShowDataForm Method Fails If Data Can't Be Found
> > > >
> > > > ypukpete wrote:
> > > > >
> > > > > I wish to auto open excel's built in dataform and if possible hide the
> > > > > worksheet it relates to.
> > > > > I have tried Dave Peterson's...
> > > > > Sub Auto_Open
> > > > > Set wks = Worksheets("Sheet2")
> > > > > With wks
> > > > > Application.DisplayAlerts = False
> > > > > .ShowDataForm
> > > > > Application.DisplayAlerts = True
> > > > > End With
> > > > > End Sub
> > > > >
> > > > > But had no success, the code breaks at .ShowDataForm
> > > > > I would like to show the dataform and hide worksheet2 if possible
> > > > > I am using excel 2000
> > > > > Thanks in advance for your help with this.
> > > > >
> > > > > --
> > > > > ypukpete
> > > >
> > > > --
> > > >
> > > > Dave Peterson
> > > >

> >
> > --
> >
> > Dave Peterson
> >

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Auto-populate data in a form based on data entered in a form mthoms Microsoft Access Forms 1 28th Mar 2008 08:44 PM
Save form, auto open anther form and populate field =?Utf-8?B?bWFseWNvbQ==?= Microsoft Access 1 19th Apr 2007 02:26 PM
Auto populate a form form an open form Far-mer Microsoft Access Forms 2 12th Mar 2007 03:40 PM
How to open a new form & auto-populate Record ID with ID from Original Form? Pamela via AccessMonster.com Microsoft Access Form Coding 0 12th Sep 2005 05:22 PM
Auto open Data-Form option Marjo van den Nieuwenhuijzen Microsoft Excel Misc 2 28th Jun 2004 10:23 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:56 PM.