473,412 Members | 2,012 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

How to get the subform to refresh after entering data on a dialog form

devlearner
Working with Access 2013
I have a subform that is part of the main report form. I want users to see entries which they would enter using the dialog form (that should be connected with this subform). The subform is in Datasheet view since there are many 'Compliance' associated with the report.
I tried using a DoCmd.Requery in the AfterUpdate and also the form load.

Don't know much of VBA code but someone told me it's one line, yet I am waiting weeks for this one line.

How can I get the datasheet to update after the dialog entry was submitted?
Aug 1 '18 #1
14 7952
zmbd
5,501 Expert Mod 4TB
devlearner
would be most helpful to post your code so we can see exactly what is happening - be sure to use the [CODE/] formatting option...

If you are calling the dialog form from within the Subform's code, AND, the dialog is "Modal" then the easiest method is on the line immediately following the call to your dialog is to use Me.Rquery

So your code might look like

Expand|Select|Wrap|Line Numbers
  1. (... code in the subform ...)
  2. DoCmd.OpenForm FormName:="Form'sName", View:=acNormal, WindowMode:=acDialog
  3. me.Requery
  4. (... the rest of your code in the subform ...)
If you calling this from the mainform then you need something like

Me.SubformCtrl.Form.Requery
"SubformCtrl" is the name of the control that holds your subform. A default unbound Subform control's name is "Child#" where the # is somewhat arbitrary.
The default name of the bound Subform control if the child is dragged and dropped is the subform's name - I HIGHLY advise changing this to avoid confusion

The Me in each case refers to the calling form.

A more specific answer can be provided if you can post your code or be much more specific on how the dialog form is being opened.
Aug 2 '18 #2
Hi zmbd

I do not have any VBA code for the forms.
For the subform inside the main form, there exists a tab control and this subform resides on one of the pages.
This subform is datasheet view and suppose to reflect data entered on the dialog form. The dialog form is opened using a button with macro control. This was easy for me because I honestly don't know VBA code. My sup told me its a simple line of code but what exactly is that code that will refresh/requery the subform (datasheet) view with the data entered in the dialog form?



This is where I am stuck. Didn't even realize that code was necessary for all these things. I was so accustomed to macros in the past.

I have tried the Me.Requery which was the first bit of code I found online while searching for a definite answer to what I am trying to achieve.

If you need any more information, please do let me know. In the meantime, I don't know how to get this datasheet to update like the backend (master table).



Attached Images
File Type: png addnew.png (20.7 KB, 3577 views)
File Type: jpg subform.jpg (69.3 KB, 4014 views)
File Type: jpg subform2.jpg (59.7 KB, 3967 views)
Aug 2 '18 #3
twinnyfo
3,653 Expert Mod 2GB
devlearner,

My first advice is to move away from Macros and toward VBA.

Macros can be converted to VBA (open the Form in Design View, under Form Design Tools, in the Design Tab, Tools Group, select "Convert Form's Macros to Visual Basic".

This will get you started. You will find 1) the switch to VBA is not really as difficult as most people think (why MS Access defaults to macros is far beyond the comprehension of any developer) and 2) VBA is so much more flexible and powerful, you will wonder why you never used it before.

I will try to take a closer look at what you have so far. Z is also a very valuable expert here. What you are trying to do does not sound very difficult--we just need to find the details and you should be good to go!
Aug 2 '18 #4
twinnyfo
3,653 Expert Mod 2GB
So.... Here is what is a bit confusing:

In image 1 above, the "Sub-Form" (which you say is in datasheet view) appears to be one and the same as frmCompliantdialog (see image 3). If this is the case, I can only assume that the record source for both objects is the same? If this is the case, then why use a dialog form to enter the data?

If the dialog form is opened up from the main form (which it looks like it does), then you will have to call the requery of the main form explicitly from the dialog form just prior to closing:

Expand|Select|Wrap|Line Numbers
  1. Forms!frm_Report.frmCompliantDialog.Form.Requery
There still might be a bit of confusion on our part as to exactly how your form(s) are structured.
Aug 2 '18 #5
PhilOfWalton
1,430 Expert 1GB
I think it would be heppful (as twinnyfo would say) helpful (as I would say) if we could see an image of your relationships. If you can show the tables fully expanded and not have too much space between the tables, that would be good.

Phil
Aug 2 '18 #6
Noted.
Honestly, this wasn't my idea to even do a dialog form. I keep having to add stuff along the way because my sup says so. Yes, I am the one developing it but it seems that what you learn in university isn't always applied in the real world.
It's so confusing for me too, to even grasp the logic of why a dialog form that is connected to the same record source.

I gather that the purpose of the dialog form is to prevent users from editing the subform. Also, there are can be more than one Compliant in any report (one to many). I haven't enforced referential integrity.
https://bytes.com/attachment.php?att...1&d=1533219036

Attached Images
File Type: png relationships.png (24.8 KB, 3822 views)
Aug 2 '18 #7
Understood. Trying to find a good starting course online atm
Aug 2 '18 #8
My apologies for the confusion.

The Report which is the main form has a PK - ReportID which is a part of the other tables as an FK.
Compliant and Report has a one-to-many relationship (ReportID).
I was asked to create the dialog-form within the Compliant and NonCompliant subforms to allow users to create many Compliant/NonCompliant and have it populate in the subforms datasheet view.
My issue is how do I get the dialog form to display the data back to the subform.
I have been trying to ask the right logical questions to grasp some understanding of what I am trying to achieve. I know it is probably simple but I am missing that little thing "simple".
Hope you understand up to there.
Aug 2 '18 #9
twinnyfo
3,653 Expert Mod 2GB
This might be really simple, but what is the Record Source for the Form frmCompliantdialog?
Aug 2 '18 #10
PhilOfWalton
1,430 Expert 1GB
Thanks for the Relationships

There are a number of points with this, that may not give you problems now, (but I suspect that is why you a having problems with Compliant), but certainly will in the future.

May I suggest
tbl_Location change from ID to LocationID. Then you know what you are refering to. (ID tells you nothing)

In tblReports, delete the field location and add LocationID. This saves holding the location in both tables. Delete the existing relationship between those two tables and create a new relationship between the two LocationIDs. Enforce referential integrity.

There should be a one to many relationship in the ReportIDs in the tbl_Reports and tbl_Compliant. That way you get as many compliants as you want per report.

Delete the table tbl_inspectors_1 from your relationship wind , then add it back. It should now show up as tbl_inspectors (without the final _1).

There is a problem with how you are handling the inspectors, and I suspect there are 3 possibilities. I need to know which one (if any is correct)
1) There is one & only one Inspector per Report.
2) There can be many inspectors for a single Report.
3) The Inspector is something to do with the Compliant rather than the Report.

Incidently, "Reports" is a very bad name as MS Access consists of Forms and Reports as well as other objects. Would "Incidents" be less confusing?

Phil
Aug 2 '18 #11
Phil,

Thank you and I used your suggestions.
The reason for the other Inspector table (tbl_inspectors_1) this was created by my sup to use as a lookup. Users will be able to select Inspectors via a combo box in the subform.
Yes, there can be many inspectors for a single Report.

I changed the name to Issue (was trying to remember if you had put Issue or Incident oops).
Thus far I left the subforms as datasheets where the users can type in the info and it will relate to the Report ID which is hidden.

Thank you again. I think I'll have to do more research and training before adding more features for the user but at this time, I really want to hand in something that works for now.
Aug 2 '18 #12
PhilOfWalton
1,430 Expert 1GB
Thanks for the reply, but unfortunately it may or may not make sense.
The problem is that you say there are many Inspectors per Issue and further on you say that the Inspector can be picked from the Compliant subform. This implies that the Inspector is associated with the compliant.

Although both statements could be true, my gut feeling is that the Inspector is associated with the Compliant rather than the Issue, and if so, can there be more than one inspector associated with each Compliant?

Phil
Aug 2 '18 #13
NeoPa
32,556 Expert Mod 16PB
Excuse me for interrupting - but isn't Compliant a boolean item of data?
Aug 2 '18 #14
zmbd
5,501 Expert Mod 4TB
devlearner:
I think at this point we may need your database.
If possible create a copy

In the COPY clear your tables

Insert a bogus record or two so that we can see the actual data interaction (John and Jane Doe to the rescue)

Zip the file and attach

There appears to be quite a few issues here (macros vs VBA - shudder), least of which is the [tbl_Inspectors_1] sitting out there in the wild - the fact that it was "needed" for a combo-box is very problematic

Also, please check your Bytes.com Inbox, I'll be sending you a little boiler plate of reference materials.
Aug 2 '18 #15

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Gilles T. | last post by:
Hi, How I can refresh a modal dialog in asp.net? I open a modal dialog in first with a dropdownlist. To add a element in my dropdownlist (table), I open a second modal dialog to ask element and...
4
by: ryan | last post by:
I'm trying to enter data from a form into two different tables. The field names are identical in both tables. I only want to enter the data once from the form. In each table a new record will be...
6
by: MLH | last post by:
I don't always get what I want when I invoke the following Me!MySubFormControl.Refresh from code running in the main form. Am I doing something wrong here? Someone suggested that I open the...
4
by: Macbane | last post by:
Hi, I have a 'main' form called frmIssues which has a subform control (named linkIssuesDrug) containing the subform sfrmLink_Issues_Drugs. A control button on the main form opens a pop-up form...
3
by: bosmatthews | last post by:
I have a main form with a subform and a second subform nested to the first subform. The data entry property for all three forms (main, subform and sub-subform) is set to "yes" because I am intending...
3
by: cheweedog | last post by:
I have a form that contains 1 subform. Everything works fine until I tab into a textbox in the bottom of the main form. The data in the subform disappears on the form, but the table is updated. ...
5
mseo
by: mseo | last post by:
hi, I have mainform with two cmdbuttons: 1- Save 2- Add Detail the mainform has subform which is set to invisible, if I click Add Detail the subform appears, if not and user clicked Save the...
1
by: AlisonP | last post by:
Hi, I am a relatively new Access programmer, but have programmed computers in Fortran and done complex modeling for years. Am learning quickly, and have managed to figure everything out so far, but...
0
by: PaulSimon | last post by:
I have a Main form which uses 3 Subforms. One for each of 3 tabs. I am entering data on the first tab form and want to total it on the second tab form in a new field. Because of my user level I need...
2
by: Amian | last post by:
So I'll explain to you everything that I'm doing and then let you know what I need help with b/c maybe I should be doing this a different way. I am trying to create a database for all patient...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.