Ms access database is updated when the subform on Mainform is updated via vba - sql

I have very strange problem I am working with MS access 2013 a application called "failure Analysis system" through which user can enter a different data for different system.
I have cread a main form to enter a data lets say "Tb_Mainform" and in this Mainform I have also one subform called "tb_subform". whenever user change one combox in Mainform the subform is updated using
Me.tb_suform.form.recordsoure = query
Me.tb_subform.requery
until now everything is gud subform is also updated. when i click on subform to navigate, it updated the table with half unfilled data.
How can i prevent this. I am opening the main form by using
DoCmd.OpenForm "tb_Mainform", WindowMode:=acDialog, DataMode:=acFormAdd, OpenArgs:=C_ID
PS: Main form and subform using the same database table.
Below is the link with the same problem as mine. it is 6 year old post but i think after that something has to be change in Access until now.
How do I prevent clicks on a subform causing updates on the main form

I have created an unbound form. It contain subforom where I am saving the records manually in vba.
comment by ChrisPadgham helped me a lot

Related

Triggering Click Event on MS Access Command Button

I am building a MS Access front-end "application" which searches multiple other MS Access Databases.
The "secondary" database has a form with a couple of text boxes, in which the user enters search parameters, a command button that executes a query, and a ListBox into which the returned values are populated
For reasons of IT bureaucracy I am not able to modify the secondary databases.
I have got code working that opens the secondary database as an Access.Application object, and populates all of the fields on the form. I have also got code working that reads the output of the searches (from a ListBox control).
What I don't have is any working solution to the problem of clicking on the command button. If I could modify the "secondary" database then I would simply change the Click event sub to Public Cmd_Click() rather than Private Cmd_Click(), however I don't have that luxury.
I have tried using:
Cmd.SetFocus
Sendkeys("{Enter}")
and also
Cmd.SetFocus
Sendkeys(" ")
Cmd.SetFocus
Sendkeys("~")
Neither of these trigger the click event
Can anyone suggest a way of triggering a click event remotely?
I am using Access 2010

Detail section of an MS Access form needs to allow access to all table records one at a time

I have a MS Access form with a subform on it. Opened on its own, the subform can run a "Find Record" action to pull any record from the single table that supplies data to it. As a child placed in the detail section of another form, however, it looks like the subform is "bound" to a single record that is selected on another control in the detail section (the other control is located outside the subform). Is there any way to "detach" the subform's dependency on the record that is current for the detail section, and allow the subform to select from a full set of records?

Trouble with SetFocus property and SubForms in Access

I have a MainForm with 4 other subforms on it. These subforms are visible and invisible based on user selection on the main form. The visible/invisible works like a charm but I am having trouble with setting the focus on these subforms. what I am doing:
on change event of a combobox makes a subform visible, then I wanted to set my focus on that form but I kept getting the runtime 2110 error. I noticed this was because all the fields on my main form are required fields and access could not transfer the focus unless these fields were filled up (setfocus worked when all the fields were filled in the main form). Now to fill up all the fields before going to the subform is counterintuitive because its not how the data to be entered will be flowing.
So my question is ----- How do I let my focus transfer to my subform before having to fill out all the required fields in the mainform!?
All help is highly appreciated as always! thanks!
IMHO that is not possible if the main form is bound to a recordsource. Whenever Access moves the focus away from a form it's default behaviour is to save the changes if there are any. It will therefore always want a valid record (i.e. no changes or valid changes).
If the subform record has a recordsource with a foreign key relationship to the recordsource of the main form you will also need the PK of the main form to have been created - which usually is a serial generated on save. If you do not have a record, you do not have an PK to pass on as FK.
Alas, if there is NO relationship between the main form and the subforms (i.e. you don't need the PK), a possibility would be to make the main form unbound and save it's contents via a button click in order to allow users to enter half of the data before switching to the subforms.
Of course you would have to handle the case of users inserting data in the subforms and then not finishing the fields on the main form.

Ms Access 2007 ComboBox

I am using Access for a quick and dirty (ADP) interface for an SQL (Express 2012) database so data entry can begin before the MVC web app interface is complete.
There is one field I want to be varchar, I would like this field to either allow the user to type in a value or select from a distinct list of values previously used in that field.
I have that part down, but the problem is when it happens, I have to refresh the recordset to see the new item in the list, so if they choose add a new record, then the last item added is not visible in the list.
So I can get the distinct list, populate the box, allow for new entry, and save that to the DB, do I have to write a code behind to repopulate the recordset, do I need to write a code behind to maintain the list paralleled to the recordset, or is there just a property I am missing?
Thanks
(Added screen showing event)
As suggested, using the on current event on the form and the after update solved the problem.
Clicking the form section detail selected the detail sections property page not the form. Selecting the form from the drop down on the property page displayed the events I was suggested to use.
Many thanks to those contributing.
As the first suggestion of this was from Remau, with assist in locating that event from hansup, I will mark remau's post as answer. Thank you to both.
Don't requery the form, just requery the combo. The best bet is probably the current event which will work if more than one person is doing data entry. It will also work if people are editing the table as well as entering data. Events that only fire when a record is added will not pick up changes to the combo contents.
Private Sub Form_Current()
Me.MyCombo.Requery
End Sub

How to edit a record through a form on MS Access?

I'm new to Microsoft Access and I'm having a trouble implementing something.
Basically, I have a form with a combo box, some text boxes, and a command button.
What I want to do is have the user select a record from the combo box, which then populates the textboxes (I've already managed to do this). Once the data has loaded into the textboxes, I want the user to be able to edit the info in the textboxes, then press the command button so that it updates that record in the table.
This looks like the same odd form where you had trouble with delete. It sounds like you are working from the wrong end. Create a form based on a table or query, then add a combobox to find records on the form based on the selection. There are wizards to guide you through. You will then have a standard Access form where everything works as expected. When textboxes are changed, the data will be updated as soon as you move to another record, there is no need for save, it is the default for Access.
If you wish to use non-standard unbound controls, you will need to update with SQL or stored queries.