many forms one (save or delete) button for all (1 Viewer)

mhakim

Member
Local time
Today, 12:32
Joined
Jan 25, 2021
Messages
72
Drears
good day

i already have many forms i want to put them in one form or navigation form or i use form with Tab control

at the end i want to make one save button for all forms
one delete button for all forms
one search button for all forms

thanks in advance
 

June7

AWF VIP
Local time
Today, 01:32
Joined
Mar 9, 2014
Messages
5,470
Data is committed to table when: 1) close table/query/form or 2) move to another record or 3) run code to save. So maybe just move to new record row on main form.

You want one delete button to delete whatever record has focus? Sounds dangerous.

One button to initiate search/filter seems reasonable.
 

mhakim

Member
Local time
Today, 12:32
Joined
Jan 25, 2021
Messages
72
Data is committed to table when: 1) close table/query/form or 2) move to another record or 3) run code to save. So maybe just move to new record row on main form.

You want one delete button to delete whatever record has focus? Sounds dangerous.

One button to initiate search/filter seems reasonable.
thanks for your reply

forget about delete button

do you have access database example how to make this
 

June7

AWF VIP
Local time
Today, 01:32
Joined
Mar 9, 2014
Messages
5,470
Sorry, no.

Really don't know what you envision for a search feature. Do you just want to activate ribbon tools? Or user input criteria into UNBOUND form controls - maybe this will help http://allenbrowne.com/ser-62.html
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 04:32
Joined
Feb 28, 2001
Messages
27,179
Unfortunately, Access is very strongly oriented towards the form that has the control that currently has the focus. (It gets that from Windows itself, which is ALSO oriented that way.) That focal point is the place were everything occurs that Access would or could do automatically. Therefore, to do what you want is NOT impossible but DOES involve some serious VBA coding because there is only one place where a SAVE action is "free." In that context, all other actions are not "free" - thus will take some work.

I can't even give you code samples because I don't know your layout, so all I can do is make suggestions.

You want to do something on open forms. You would need to make a loop through the Forms object, which can include Forms( n ) - n being a number starting from 0 and running to Forms.Count - 1 in a loop. Each form referenced in this way can be manipulated - but there is this little "gotcha" floating in the mix... What do you want to happen if one of these forms was incomplete (not ready to be saved) but wasn't the one in focus when you hit the button? In fact, if you are using a switchboard, NONE of the forms is in focus the moment you click this proposed SAVE button because the form that holds the SAVE button suddenly gains focus anyway.

Depending on which version of Access you are using, you might need to test Forms( n ).IsOpen to see if the form is even open at the moment. And if you are using a switchboard form, it WILL be open but might not be possible to SAVE anyway, since switchboards aren't usually bound. So there's another test to be considered.

I know you have some goal in mind, but I wonder if you realize that sometimes, matters of practicality and complexity will get in the way. If you are going to allow multiple forms to be open simultaneously, you will have complex control issues to address. Which, if you think about it for a bit, is exactly why Access is so tightly centered around the form that currently has focus. It DOESN'T want to deal with the complex control issues so leaves that for you to code with VBA.
 
Last edited:

theDBguy

I’m here to help
Staff member
Local time
Today, 02:32
Joined
Oct 29, 2018
Messages
21,471
Hi. Sounds like you could use a custom ribbon.
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 10:32
Joined
Jul 9, 2003
Messages
16,281
i already have many forms

I'd be surprised if you actually need all of these forms you mention.

It is very common for people to have a Form which they apply the cookie-cutter principle to, in that they make a copy of it, and make a very small change to it. Now you have two forms, where in fact you would have been better off making the change you require with VBA code.

Instead of making many copies, enhance your single form with VBA code. This approach will go a long way to solving the problem you find yourself in.
 
Last edited:

oleronesoftwares

Passionate Learner
Local time
Today, 02:32
Joined
Sep 22, 2014
Messages
1,159
i already have many forms i want to put them in one form or navigation form or i use form with Tab control
i presume the forms have various tables as record source, why would you want to have many forms into a single form.

When you say many, how many forms are you referring to?
 

Minty

AWF VIP
Local time
Today, 10:32
Joined
Jul 26, 2013
Messages
10,371
If you swap all your forms in and out of a Subform control, then the command buttons on the main form could be made to Save or Close the subform (e.g. swap it back to the main menu version)

This is exactly how the inbuilt navigation forms work.
 

oleronesoftwares

Passionate Learner
Local time
Today, 02:32
Joined
Sep 22, 2014
Messages
1,159
Another question to be answered is are there any of the forms that have subform?
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 05:32
Joined
Feb 19, 2002
Messages
43,266
i want to put them in one form or navigation form
No way you can use an Access navigation form this way. In a navigation form, one and ONLY one subform is ever loaded at one time. That means that when you move from form to form, the form you are leaving always gets saved and there is nothing you can do to stop it. If you use a normal tab control, You you almost certainly have the same problem though. Moving focus from a main form to a subform, saves the mainform data if it is dirty and conversely moving focus from a subform to the mainform, saves the subform data. And if memory serves, moving from one subform to a different subform, also forces a save but you can confirm that without investing a lot of work in this edeavor.

I would only ask you to reconsider this dependency. It sounds like a poorly designed schema.
 

Users who are viewing this thread

Top Bottom