473,382 Members | 1,380 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,382 software developers and data experts.

How to Requery after a table insert

102 64KB
Front End: MS Access 2010
Back End: SQL Server 2008

I have a form (form A) that displays records via a query. There is a button on form A that opens form B. Form B adds a table entry that to the table shown on form A. Form B closes and Form A has control. How can I do a requery so that form A displays the newly created table entry done by form B.
Thanks in advance.
Aug 22 '14 #1

✓ answered by jforbes

This is what I do when I’m in your situation. I have this function in a Module just waiting around:

Expand|Select|Wrap|Line Numbers
  1. Function isLoaded(ByRef sFormName As String) As Boolean
  2.  
  3.     ' Determines if a form is loaded
  4.     Dim i As Integer
  5.  
  6.     isLoaded = False
  7.     For i = 0 To Forms.Count - 1
  8.         If Forms(i).FormName = sFormName Then
  9.             isLoaded = True
  10.             Exit Function
  11.         End If
  12.     Next
  13. End Function
In FormB, I put this code right after the code that inserts the new record.
Expand|Select|Wrap|Line Numbers
  1. If isLoaded("FormA") Then
  2.     Forms!FormA.Requery
  3. End If

3 1781
jforbes
1,107 Expert 1GB
This is what I do when I’m in your situation. I have this function in a Module just waiting around:

Expand|Select|Wrap|Line Numbers
  1. Function isLoaded(ByRef sFormName As String) As Boolean
  2.  
  3.     ' Determines if a form is loaded
  4.     Dim i As Integer
  5.  
  6.     isLoaded = False
  7.     For i = 0 To Forms.Count - 1
  8.         If Forms(i).FormName = sFormName Then
  9.             isLoaded = True
  10.             Exit Function
  11.         End If
  12.     Next
  13. End Function
In FormB, I put this code right after the code that inserts the new record.
Expand|Select|Wrap|Line Numbers
  1. If isLoaded("FormA") Then
  2.     Forms!FormA.Requery
  3. End If
Aug 22 '14 #2
twinnyfo
3,653 Expert Mod 2GB
jforbes,

Your first block of code is simple and seems like it could be quite useful at times.

Of course, line 2 of your second block is the only line needed if we know the form is loaded--but I like the double-check and error prevention concepts you present.

Nice to have you contributing to the site!
Aug 25 '14 #3
sc5502
102 64KB
This worked. Thanks so much.
Aug 25 '14 #4

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

Similar topics

1
by: PT | last post by:
I got a problem. And thats..... First of all, I got these three tables. ------------------- ------------------ ---------------------- tblPerson tblPersonSoftware ...
0
by: Eric | last post by:
I'm trying to insert data for a real-time application that demands less than 3 second receipt-to-commit time, has a relatively large (500,000 records/hr) data rate, and requires access times on the...
1
by: Mike Morris | last post by:
I have an app server running on top of Oracle 8i and need a way to have a table insert trigger call a servlet url in order to generate email to inform users of the event. I have seen references...
0
by: James Fryer | last post by:
Assuming a legal SELECT statement, this works fine: CREATE TABLE Foo SELECT ... but this does not: CREATE TABLE Foo (SELECT ...) This is a problem for me as I'd like to use the output of...
8
by: Bri | last post by:
Greetings, I'm having a very strange problem in an AC97 MDB with ODBC Linked tables to SQL Server 7. The table has an Identity field and a Timestamp field. The problem is that when a new record...
9
by: Jack | last post by:
Hi, I am gathering the input values to a form using Request.form method from the processing page. After all the data is captured, I am building sql statement out of it. Using a response.write...
0
by: Steven Blair | last post by:
Hi, Would be grateful if anyone with a high understanding of the SqlDataSource and FormView could have a look at my example and my problems. This has really been puzzling me for some time, and...
6
by: Peter Nurse | last post by:
For reasons that are not relevant (though I explain them below *), I want, for all my users whatever privelige level, an SP which creates and inserts into a temporary table and then another SP...
6
by: pretzla | last post by:
I have a PL/SQL script where I load data from a stored procedure into bind variables. Then, I insert that data from the bind variables into an Oracle table with a simple insert statement. The...
5
by: tvnaidu | last post by:
Getting an error "table insert failed for eventLog" any idea what is the reason?, I have this table called "eventLog", earlier DB comesup, now I saved more data and I am getting the above error when...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?

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.