Kamis, 26 Mei 2011

RE: [MS_AccessPros] Re: On Dirty

 

Steven-

As I told you, when the focus moves to the main form from the subform, Access
does an auto-save. I like to design my subforms in Continuous Form view with a
header that contains Cancel and Save buttons. My Cancel code looks like:

Private Sub cmdCancel_Click()

If Me.Dirty Then Me.Undo

End Sub

If on the main form, I also add:

DoCmd.Close acForm, Me.Name

John Viescas, author
Microsoft Office Access 2010 Inside Out
Microsoft Office Access 2007 Inside Out
Building Microsoft Access Applications
Microsoft Office Access 2003 Inside Out
SQL Queries for Mere Mortals
http://www.viescas.com/
(Paris, France)

-----Original Message-----
From: MS_Access_Professionals@yahoogroups.com
[mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of S and M
Sent: Thursday, May 26, 2011 11:35 PM
To: MS_Access_Professionals@yahoogroups.com
Subject: [MS_AccessPros] Re: On Dirty

John,

Ok, so here is what I did. In the On Dirty event for the main form and the
subform I set cmdNewMember.Enable = False. This will prevent the selection of a
new record in the middle of an edit.

I then set it back to True with the save cmdbutton.

I would like to add a Canel button (DoCmd.DoMenuItem acFormBar, acEditMenu,
acUndo, , acMenuVer70) to duplicate hitting the escape key during editing but
that does not seem to work with a subform either.

I have ready that sending keystrokes is frowned upon. Any suggestions on the
correct way to do this.

Thanks, Steven

--- In MS_Access_Professionals@yahoogroups.com, "John Viescas" <john@...> wrote:
>
> Steven-
>
> If your command button is on the outer form, then any "dirty" record in the
> subform will be automatically saved by Access as soon as the focus moves to
the
> outer form. You can test for Dirty in the subform only as long as the focus
> stays there.
>
> John Viescas, author
> Microsoft Office Access 2010 Inside Out
> Microsoft Office Access 2007 Inside Out
> Building Microsoft Access Applications
> Microsoft Office Access 2003 Inside Out
> SQL Queries for Mere Mortals
> http://www.viescas.com/
> (Paris, France)
>
>
>
> -----Original Message-----
> From: MS_Access_Professionals@yahoogroups.com
> [mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of S and M
> Sent: Thursday, May 26, 2011 10:29 PM
> To: MS_Access_Professionals@yahoogroups.com
> Subject: [MS_AccessPros] Re: On Dirty
>
> John,
>
> This works great. I also want to check Dirty on the subform as well. I
thought
> it would be
>
> Me!subform.form.Dirty or Me!Subform1.Form!Dirty but neither work.
>
> I have this link,...http://access.mvps.org/access/forms/frm0031.htm but maybe
I
> cannot do this.
>
> Thanks, Steven
>
> --- In MS_Access_Professionals@yahoogroups.com, "John Viescas" <john@> wrote:
> >
> > Steven-
> >
> > In the code for your command button, add:
> >
> > ' If unsaved changes
> > If Me.Dirty Then
> > If vbYes = MsgBox("Do you want to save changes before " & _
> > " you add a new record?", vbYesNo + vbQuestion + vbDefaultButton2)
Then
> > ' Save the record
> > Me.Dirty = False
> > Else
> > ' Bail
> > Exit Sub
> > End If
> > End If
> > ' Go to new record here
> >
> > John Viescas, author
> > Microsoft Office Access 2010 Inside Out
> > Microsoft Office Access 2007 Inside Out
> > Building Microsoft Access Applications
> > Microsoft Office Access 2003 Inside Out
> > SQL Queries for Mere Mortals
> > http://www.viescas.com/
> > (Paris, France)
> >
> >
> >
> > -----Original Message-----
> > From: MS_Access_Professionals@yahoogroups.com
> > [mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of S and M
> > Sent: Thursday, May 26, 2011 9:27 PM
> > To: MS_Access_Professionals@yahoogroups.com
> > Subject: [MS_AccessPros] On Dirty
> >
> > Ok,...I now have a combo box I can select an entry to edit. I also added a
> > command button to select a new record if it is an addition.
> >
> > To prevent accidentally changing data I think I need to add code so that if
> the
> > cmdNewMember button is clicked, a message box will pop up asking to save the
> > current changes.
> >
> > Is the On Dirty event that right place to put this code?
> >
> > It is my understanding (please correct if I am wrong) that Dirty will be
true
> if
> > anything on the form has been changed (not by code). So If Dirty is false,
> then
> > going to a new record is ok,...If Dirty is true, then we either have to save
> the
> > changes or cancel.
> >
> > Thanks for all the help,
> >
> > Stevn
> >
> >
> >
> > --- In MS_Access_Professionals@yahoogroups.com, "John Viescas" <john@>
wrote:
> > >
> > > Steven-
> > >
> > > You need a separate *unbound* combo box named cmbMemberLookup. (Unbound
> means
> > > the control has no Control Source.) Use the same Row Source that you had
> for
> > > MemberID, and add this code:
> > >
> > > Private Sub cmbMemberLookup_AfterUpdate()
> > >
> > > Me.Recordset.FindFirst "MemberID = " & Me.cmbMemberLookup
> > >
> > > End Sub
> > >
> > > Private Sub Form_Current()
> > >
> > > ' Keep the search combo in sync with the current record
> > > Me.cmbMemberLookup = Me.MemberID
> > >
> > > End Sub
> > >
> > >
> > > John Viescas, author
> > > Microsoft Office Access 2010 Inside Out
> > > Microsoft Office Access 2007 Inside Out
> > > Building Microsoft Access Applications
> > > Microsoft Office Access 2003 Inside Out
> > > SQL Queries for Mere Mortals
> > > http://www.viescas.com/
> > > (Paris, France)
> > >
> > >
> > >
> > > -----Original Message-----
> > > From: MS_Access_Professionals@yahoogroups.com
> > > [mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of S and M
> > > Sent: Wednesday, May 25, 2011 11:53 PM
> > > To: MS_Access_Professionals@yahoogroups.com
> > > Subject: [MS_AccessPros] Selecting a record set with a combo box
> > >
> > > Hi all,
> > >
> > > I created a form with a sub form to edit / enter data into two tables.
> > > Everything works great and I can edit / add records and they save fine.
> > >
> > > My problem will be when the tables get several hundred entries. I need to
> be
> > > able to select the entry I want to edit from a drop down box.
> > >
> > > The two forms are linked by MemberID,..the main forms record source is
> > >
> > > the main table and the subform is a select statement of other table.
> > >
> > > If I change the memberID field to a combo box, and add a select statement,
> it
> > > will list the ID's but will not allow me to select one.
> > >
> > > What am I not doing?
> > >
> > > Thanks, Steven
> > >
> > >
> > >
> > > ------------------------------------
> > >
> > > Yahoo! Groups Links
> > >
> >
> >
> >
> >
> > ------------------------------------
> >
> > Yahoo! Groups Links
> >
>
>
>
>
> ------------------------------------
>
> Yahoo! Groups Links
>

------------------------------------

Yahoo! Groups Links

__._,_.___
Recent Activity:
MARKETPLACE

Find useful articles and helpful tips on living with Fibromyalgia. Visit the Fibromyalgia Zone today!


Stay on top of your group activity without leaving the page you're on - Get the Yahoo! Toolbar now.

.

__,_._,___

Tidak ada komentar:

Posting Komentar