Ask a Question related to Microsoft Access, Design and Development.
-
Tim Cali #1
Re: Saving a value if a form is closed while focus is still in the control
Strange. When I first tested it, the value was not saved. Now it seems to
save when I close the form.
How do you programmatically save the value for the selected control?
(assuming it has been validated)?
"Hugh O'Neill" <mail@hughoneill.co.uk> wrote in message
news:bfiuv5$n4f$1@sparta.btinternet.com...> Tim Cali wrote:
>>> > I have a form with a 'Close' button. If focus is still on a textbox or
> > combobox, and the close button is pressed, the form will close without
> > saving data. How can I get the last-entered value to save if somebody
> > doesn't know that they have to exit the control for Access to know to
> > save the value?
> >
> > As a workaround, I set focus to some other control in the form, which
> > seems to work, however if the little 'x' in the form is pressed, I'll
> > run into that problem again. How can I guarantee to save the last
> > entered value if somebody closes the form?
> >
> > I suppose I could set focus to another control on the Form_Close
> > event, but that seems odd.
> >
> > Thanks.
>
> If the Form is bound to its record source, then closure will save the
> current record automatically. If you wish to ensure the record entries
> are complete, you will need to write code to test and validate each
> entry text box. Then only enable your 'Close' button if the testing
> proves True. To remove the 'X' close box, chage the form border type
> to, say, Dialogue.
>
> hth
>
> Hugh
Tim Cali Guest
-
Taking focus from a control
In my app, I have a DataGrid, and when a row is double-clicked, a new view is put up showing the data. I also add eventListeners to the stage for... -
Flash form focus
Is there a way to establish the focus on a specific field (at page load) using the new MX7 Flash forms? -
focus/lost focus of custom control
Hi new to .NET and have a question. What I want to do if have a custome control (contains a table grid of text boxes) and multiple instances... -
Control focus
Hi guys, How to Focus a TextBox on page load? I have this function: public static void FocusControl(Page pagina, WebControl control) {... -
Which control had focus before postback?
Hi, Is it possible to retrieve the control that had the focus when the page was posted back? Because the focus is lost when a postback occurs... -
Hugh O'Neill #2
Re: Saving a value if a form is closed while focus is still in the control
Tim Cali wrote:
> Strange. When I first tested it, the value was not saved. Now it
> seems to save when I close the form.
>
> How do you programmatically save the value for the selected control?
> (assuming it has been validated)?
>
>
> "Hugh O'Neill" <mail@hughoneill.co.uk> wrote in message
> news:bfiuv5$n4f$1@sparta.btinternet.com...> > Tim Cali wrote:
> >> >> > > I have a form with a 'Close' button. If focus is still on a
> > > textbox or combobox, and the close button is pressed, the form
> > > will close without saving data. How can I get the last-entered
> > > value to save if somebody doesn't know that they have to exit the
> > > control for Access to know to save the value?
> > >
> > > As a workaround, I set focus to some other control in the form,
> > > which seems to work, however if the little 'x' in the form is
> > > pressed, I'll run into that problem again. How can I guarantee to
> > > save the last entered value if somebody closes the form?
> > >
> > > I suppose I could set focus to another control on the Form_Close
> > > event, but that seems odd.
> > >
> > > Thanks.
> >
> > If the Form is bound to its record source, then closure will save
> > the current record automatically. If you wish to ensure the record
> > entries are complete, you will need to write code to test and
> > validate each entry text box. Then only enable your 'Close' button
> > if the testing proves True. To remove the 'X' close box, chage the
> > form border type to, say, Dialogue.
> >
> > hth
> >
> > Hugh
Saving the value of a single control doesn't really mean anything in a
database as the value of a bound control will normally be just one
element of the whole record. Normally you save the Record. As I said,
this is done automatically by Access when you close the Form or when
you move from the current Record or Form. If you want to save the
changed Record programatically at some other point, then you can use
the following code to do this:
If Me.Dirty then Me.Dirty = False
in, say the click event of a 'Save' button.
What this does is as follows:
As you create a new Record or change a value in an existing one, the
Dirty property is set to True - the Record is 'Dirty'. Setting the
Dirty property to False, forces the Record to be saved in order that
the Dirty property can actually be False as you have told it to be.
hth
Hugh
Hugh O'Neill Guest



Reply With Quote

