Related Objects to run again with new record added (1 Viewer)

Steven_Bash

Registered User.
Local time
Today, 07:35
Joined
May 9, 2018
Messages
27
So I have this database with tables, queries and forms. On this form you'd save a new record. In vba i have it as the "if me.dirty...etc" format and it saves to the table correctly. But then i have this query that gets its data from that table and goes to a couple more tables and queries eventually to the final form. How can I get that first query to grab the new record from the table that got it from the save new record form and for all the other objects rerun/refresh afterwards to attain the new data? I think itd have to be thru VBA in the form once i click "save new record". i've tried requery, openquery, refresh. Simplest way to describe what i need: this works(click "save new record" on form -> table) then what i need help with(table->query-> rest of objects). please help. thanks!
 

James Dickinson

PigeonPie
Local time
Tomorrow, 00:35
Joined
May 10, 2018
Messages
43
Hi I would love to help.

Is the query you speak of the recordsource for your saveform? What type of query is your query and what does it do? is your query the recordsource of a subform?

perhaps all you need is CurrentDb.Execute "YOUR QUERY NAME HERE"
 

Cronk

Registered User.
Local time
Today, 22:35
Joined
Jul 4, 2013
Messages
2,774
You could order your query so that it selects the top 1 record and order the records in descending ID order. That way your query would always show the last record added. Alternatively, you could make the base your query on the value of the text box containing the ID of the record just added in the form.

If you just want to update the display on any other open forms based on the table where the new record has been saved, then add to your button code
Code:
forms!YourFormname.requery
 

Steven_Bash

Registered User.
Local time
Today, 07:35
Joined
May 9, 2018
Messages
27
Hi I would love to help.

Is the query you speak of the recordsource for your saveform? What type of query is your query and what does it do? is your query the recordsource of a subform?

perhaps all you need is CurrentDb.Execute "YOUR QUERY NAME HERE"
No the table is the recordsouce of that saveform. then that query is a select query which then goes to an append query and a couple other object down the line. So i would need all the other objects to rerun/refresh their data to include the new one.
 

James Dickinson

PigeonPie
Local time
Tomorrow, 00:35
Joined
May 10, 2018
Messages
43
Simply rerun the query then. Once a record is saved to the table the query will be able to read it, just re-run the query.
 

James Dickinson

PigeonPie
Local time
Tomorrow, 00:35
Joined
May 10, 2018
Messages
43
DoCmd.OpenQuery "yourQueryName", acViewNormal, acEdit
OR

CurrentDb.OpenRecordset("yourQueryName")

Or
CurrentDb.Execute "yourQueryName"

depending on what you are doing with it
 

Steven_Bash

Registered User.
Local time
Today, 07:35
Joined
May 9, 2018
Messages
27
DoCmd.OpenQuery "yourQueryName", acViewNormal, acEdit
OR

CurrentDb.OpenRecordset("yourQueryName")

Or
CurrentDb.Execute "yourQueryName"

depending on what you are doing with it

I think i've tried those but lemme see at work tmrw morn. ill get back to you round 8:30 then !
 

Steven_Bash

Registered User.
Local time
Today, 07:35
Joined
May 9, 2018
Messages
27
Yea I got it to work with those cmds, it was all about the placement of it in the code.
 
Last edited:

Users who are viewing this thread

Top Bottom