A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Putting Generic Buttons on a Subform



 
 
Thread Tools Display Modes
  #1  
Old May 16th, 2006, 12:03 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default Putting Generic Buttons on a Subform

Hi Everyone,

Just a quick question to see if it is possible to design a generic form with
"Save and close", "Undo and close" ,"Next" and "Previous" buttons which
affect whichever form it is added to as a subform?

I have tried the following (and variations) but I can't get it to work:

Private Sub cmdNext_Click()
Me.Parent.SetFocus
DoCmd.GoToRecord , , acNext
End Sub

Does anyone have any suggestions?

Thanks in advance,

John


  #2  
Old May 16th, 2006, 12:14 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default Putting Generic Buttons on a Subform

Stephen Lebans has an example of how to do that in this database:
http://www.lebans.com/DownloadFiles/A97NavButtons.zip

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"John Ortt" wrote in message
...

Just a quick question to see if it is possible to design a generic form
with "Save and close", "Undo and close" ,"Next" and "Previous" buttons
which affect whichever form it is added to as a subform?

I have tried the following (and variations) but I can't get it to work:

Private Sub cmdNext_Click()
Me.Parent.SetFocus
DoCmd.GoToRecord , , acNext
End Sub



  #3  
Old May 16th, 2006, 01:51 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default Putting Generic Buttons on a Subform

The way I do that is a have a standard module I call modFormOperations. For
a short example, here is the function to close a form:

Public Function CloseForm(ByRef SomeForm As Form)
DoCmd.Close acForm, frm.Name, acSaveNo
End Function

To use it from a button on any form, just enter this in the Click event
property text box of the Properties Dialog in design mode:

=CloseForm(Forms!MyFormName)

The advantages of using this sort of technique:
1. Less work on your part
2. Things work consistently (Users like that)
3. The form stays lighter and therefore loads more quickly.

One other thing. Be consistent in control naming. That way, when you need
to address a control by name in one of your functions

"John Ortt" wrote:

Hi Everyone,

Just a quick question to see if it is possible to design a generic form with
"Save and close", "Undo and close" ,"Next" and "Previous" buttons which
affect whichever form it is added to as a subform?

I have tried the following (and variations) but I can't get it to work:

Private Sub cmdNext_Click()
Me.Parent.SetFocus
DoCmd.GoToRecord , , acNext
End Sub

Does anyone have any suggestions?

Thanks in advance,

John



  #4  
Old May 17th, 2006, 08:26 AM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default Putting Generic Buttons on a Subform

I'm interested, too, but can't find the proper, safe, way to do "Save and
close", "Undo and close". Any good link? The example db below deals only
with record navigation
--
Fjordur

"Allen Browne" wrote in message
...
Stephen Lebans has an example of how to do that in this database:
http://www.lebans.com/DownloadFiles/A97NavButtons.zip


"John Ortt" wrote in message
...

Just a quick question to see if it is possible to design a generic form
with "Save and close", "Undo and close" ,"Next" and "Previous" buttons
which affect whichever form it is added to as a subform?

I have tried the following (and variations) but I can't get it to work:

Private Sub cmdNext_Click()
Me.Parent.SetFocus
DoCmd.GoToRecord , , acNext
End Sub



  #5  
Old May 17th, 2006, 10:00 AM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default Putting Generic Buttons on a Subform

Save and close:
With Me
If .Dirty Then
.Dirty = False
End If
DoCmd.Close acForm, .Name
End With

Undo and close:
With Me
If .Dirty Then
.Undo
End If
DoCmd.Close acForm, .Name
End With

If the code goes into an unbound subform, replace the first line in each of
the above with this:
With Me.Parent

Add error handling of course: the attempt to set Dirty to false generates a
trappable error if the record cannot be saved for any reason (e.g. required
field missing.)

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Fjordur" wrote in message
...
I'm interested, too, but can't find the proper, safe, way to do "Save and
close", "Undo and close". Any good link? The example db below deals only
with record navigation
--
Fjordur

"Allen Browne" wrote in message
...
Stephen Lebans has an example of how to do that in this database:
http://www.lebans.com/DownloadFiles/A97NavButtons.zip


"John Ortt" wrote in message
...

Just a quick question to see if it is possible to design a generic form
with "Save and close", "Undo and close" ,"Next" and "Previous" buttons
which affect whichever form it is added to as a subform?

I have tried the following (and variations) but I can't get it to work:

Private Sub cmdNext_Click()
Me.Parent.SetFocus
DoCmd.GoToRecord , , acNext
End Sub



  #6  
Old May 17th, 2006, 11:19 AM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default Putting Generic Buttons on a Subform - Nearly There

Thanks for the Help Everyone,

Stephen's record navigation is an excellent help and has solved most of my
problems.

The only minor issue I am still having is that the undo button I added to
Stephen's form will not work.

The following is the code I am using:

Private Sub cmdUndo_Click()
If Me.Parent.Dirty Then
Me.Parent.SetFocus
DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
DoCmd.Close , , acSaveNo
Else
Me.Parent.SetFocus
DoCmd.Close , , acSaveNo
End If
End Sub

I think it is not working because by activating the subform the main form is
being saved making it clean.

If anyone knows a way around this I'd really appreciate it.

Thanks again,

John


  #7  
Old May 17th, 2006, 11:20 AM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default Putting Generic Buttons on a Subform - Nearly There

I think Allen has just answered my question above

"John Ortt" wrote in message
...

snipped


  #8  
Old May 17th, 2006, 11:26 AM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default Putting Generic Buttons on a Subform - Nearly There

No, It hasn't worked.

It still seems to be saving the record before accessing the subform.

Any suggestions?

"John Ortt" wrote in message
...
I think Allen has just answered my question above

"John Ortt" wrote in message
...

snipped



  #9  
Old May 17th, 2006, 12:04 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default Putting Generic Buttons on a Subform - Nearly There

If I understand what you're trying to do, I don't believe there's any way
around it.

If you've got a new record on the parent form, and you move to the subform
(or, more generically, you take focus off the parent form), the record on
the parent form is going to be saved.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"John Ortt" wrote in message
...
No, It hasn't worked.

It still seems to be saving the record before accessing the subform.

Any suggestions?

"John Ortt" wrote in message
...
I think Allen has just answered my question above

"John Ortt" wrote in

message
...

snipped





  #10  
Old May 17th, 2006, 01:31 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default Putting Generic Buttons on a Subform - Nearly There


"Douglas J Steele" wrote in message
...
If I understand what you're trying to do, I don't believe there's any way
around it.

If you've got a new record on the parent form, and you move to the subform
(or, more generically, you take focus off the parent form), the record on
the parent form is going to be saved.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


You have confirmed what I was afraid of......Thanks Doug


 




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Main form -subform keeping count babs Using Forms 22 May 5th, 2006 03:50 AM
Form data to automatically upldate a field in the subform Database User Using Forms 6 November 8th, 2005 09:01 PM
Subform on Subform problem JohnB Using Forms 4 April 10th, 2005 12:52 PM
Subform Refresh Problem (but only with an unbound combo box control) Barry Skidmore Using Forms 1 December 21st, 2004 01:19 AM
Subform command buttons Deb Smith Using Forms 1 August 20th, 2004 03:49 AM


All times are GMT +1. The time now is 01:38 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.