Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Don't save record until button clicked 4

Status
Not open for further replies.

krets

Technical User
Dec 29, 2006
214
US
Is there a way to prevent a record from being saved until the user clicks a "Save" button on the form?
 
There are a couple of methods. One is to disable record updating by the form, and the other would be sort of a "hack", I guess. That is to not allow any of the text boxes, combo boxes, list boxes, or anything else to move focus to the "next record."

The first method would probably be the "cleaner" method. But I'd imagine you'd also want to incorporate the second method so as to be sure that record gets saved before going to a brand new record.

Of course, I think the first option is an option in itself, but I may be remembering incorrectly, as I couldn't find where to do that right off hand.

--

"If to err is human, then I must be some kind of human!" -Me
 
How are ya krets . . .

In a bound form anytime the currently edited record [blue]loses focus[/blue] or the [blue]form is closed[/blue], the [purple]record is automatically saved.[/purple]

This limits your needs to an [blue]Unbound Form![/blue] . . .


Calvin.gif
See Ya! . . . . . .
 
Ah, an unbound form is what I want.

Thanks!
 
Yes, I'd say simpler is always better. That's a much better way than the "hack" I mentioned! [wink]

--

"If to err is human, then I must be some kind of human!" -Me
 
OK, so another related question:

I'm used to working with bound forms and declaring a 'DoCmd.GoToRecord... acNewRecord' to clear the fields and enter a new record.

With an unbound form, what is the appropriate method to clear all the fields and start fresh when the user clicks "Save"?
 
krets . . .

This post changes the answer to your post origination to [blue]Yes![/blue] [thumbsup2] . . . [blue]and with bound form![/blue] [thumbsup2]
krets said:
[blue]I'm used to working with bound forms . . .[/blue]
This brought back memory of a thread I completed not too long ago about adding new records at the top of the form instead of the bottom. A quick search im my library and viola thread702-1309854

[ol][li]In my post there skip 1. and remember you can use the [blue]form footer[/blue] as well (the choice is yours).[/li]
[li]Instead of the last textbox use your save button to append.[/li]
[li]Also don't forget to set the forms [blue]Allow Additions[/blue] property to [blue]No[/blue].[/li][/ol]
[blue]Let me know if you need any assistance! . . .[/blue]

Calvin.gif
See Ya! . . . . . .
 
For Single bound forms: with the Cycle property of the form set to 'Current Record' and test the Dirty property in the Unload event, plus removing default navigation buttons, that can be done. Navigation can be made with command buttons.

However, unbound is (in my opinion) better, as it's more to code, but the control is total.

HTH

[pipe]
Daniel Vlas
Systems Consultant

 
I went with the unbound form and I really like how it worked out. I don't want the users to have access to any other records besides the one they are entering so the unbound is ideal.

I ended up clearing the fields by setting them to blank with VBA after updating the recordset:

Me![Fieldname].Value = ""

Any problems with that?
 
What I meant was technically, is that a sound way to go about it? I'd like to know for future endeavors so I'm learning to do this the "right" way.
 
Don't know that it really makes a difference, but a remember a discussion of vbNullString stating that it was a little cleaner somehow than just using "".

So, I'd suggest this:

Me![Fieldname].Value = vbNullString

Some of the other guys may can expand upon the thought if need be, I'm sure.

--

"If to err is human, then I must be some kind of human!" -Me
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top