473,948 Members | 21,083 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Requery problem

76 New Member
I am experiencing two distinct problems with the Requery method in Access 2003.

Problem 1: I have a series of text boxes on my form. The control sources of these text boxes are used in calculations in a query. The results of the query are displayed in a subform (continuous form) on my main form. I want the text boxes in the subform to update after any of the text boxes on the main form are updated. I have tried to requery the subform on each textbox's After Update event. However, the requeried results do not display unless I shift the focus to the subform. This is truly bizarre behavior. Any ideas? I have a temporary fix in place where I refresh the database on the changes in the mainform text boxes. However, I am afraid that as my DB grows, this get slow.

Problem 2: The main form's After Update event does not seem to fire unless the focus is shifted to one of its subforms. This is causing a big pain in that I have to write code for each control's After Update event instead of just having the code in the form's After Update event. We are calculating health insurance rates here, so the queries are quite complicated and rely on several checkboxes, combos, and text boxes across several tabs in a tab strip. Any ideas on this one?

Thanks in advance,
jpatchak
Oct 30 '06 #1
2 3744
MMcCarthy
14,534 Recognized Expert Moderator MVP
To requery a subform from its main form

Me.SubformName. Form.Requery

To requery a subform from a form other than its main form

Forms!MainFormN ame!SubFormName .Form.Requery
Oct 30 '06 #2
ebs57
18 New Member
Did you try requery more than once? I've no idea if it will work or not but I had a similar problem with ACC2003: A control would not refresh with data that was extracted from its bound table and concatenated with a simple string.

What I wanted was the form to display a unique identifier. When the form opened and closed the identifier worked; when the form was opened and the user advanced to a new record, the identifier would return a null because the table data was somehow not loaded yet. The code was invoked from the form's OnCurrent event. Here is the code that did NOT work:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2.  
  3.     Dim idPrefix As String
  4.     idPrefix = "ABCDE"          ' Fixed ID Field
  5.  
  6.     With Me
  7.         If IsNull(.TID) Then
  8.             .TID = idPrefix & Form!ID
  9.         End If
  10.     End With
  11.  
  12. End Sub
  13.  
Here is the code that DOES work:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2.  
  3.     Dim idPrefix As String
  4.     idPrefix = "ABCDE"          ' Fixed ID Field
  5.  
  6.     With Me
  7.         If IsNull(.TID) Then
  8.            .TID = ""      ' dummy load to initialise control or refresh data???
  9.            .TID = idPrefix & Form!ID
  10.         End If
  11.     End With
  12.  
  13. End Sub
  14.  
Perhaps a similar problem is occurring with your form. Maybe duplicating another .Requery is all you need. I was able to run the debugger and actually see the control finally return a valid number once I loaded my control twice!

I assure you I stumbled upon this quite by accident (like most of my coding) so I cannot explain why it works but I believe it has something to do with updating table data and synchronising it to the form.
Jun 8 '07 #3

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

Similar topics

3
2412
by: pbbriggs | last post by:
I will try to be as descriptive as possible, but this error has me stumped and I am not sure what relevant info to include.... I am running Access XP on a Windows XP machine. I initially began developing an app in Access 2000 but converted it several months ago to XP. So the app is now Access XP format also. My app is crashing on a regular basis, with the totally non-descript Microsoft error (Microsoft Access has encountered a...
6
5488
by: Tim Marshall | last post by:
Here's the situation. A form, frmSetUp, with a subform control called subExplain with a source object form frmSetUpSubDefineSides. The source object is a bound form, displaying a few records, no edit, adds, filters, etc, are permitted on the subform. An add or edit button on the subform is clicked opening an unbound form, frmSetUpSideAdd, (populated with values from the above subform if this is an edit of an existing record) for data...
4
7039
by: Dave Boyd | last post by:
Hi, I have two very similar forms each with a subform. The main form gets a few fields from the user and passes this back to a query that the subform is bound to. The requery is done when the user enters the last qualifying field on the main form. In one case this works fine, the subform shows the data the user wants to update -- which means showing all the data put in previously (ie showing this via the requery and the continuous...
20
10710
by: MS | last post by:
Access 97 I want to requery the data being displayed on a form, then I want to return to the record I was in. Why doesn't this code work? Private Sub CmdRefsh_Click()
2
1757
by: Gianluca_Venezia | last post by:
Scenary: a main form contains two sub-form unbounded. Sub-form "one" contains a list of products. Sub-form "two" contains the items of the selected product. Event: when, from sub-form "two", it's modified type or quantity of items, I need to execute .requery's method on sub-form "one"; Problem:
2
10908
by: F. Michael Miller | last post by:
I need to requery a subform from a third form and can't seem to get it to work. frmForm1 has frmAddress as a subform. The button cmdReviseAddress opens the form frmUpdateAddress where all of my validation work is done and the new record is added. However, the new address is not being displayed in the subform. If I use the command
1
4041
by: ANDRESUK | last post by:
All I have a listbox in a form footer. When the form footer is visible the listbox requeries fine but when I turn the form footer visible=false the listbox does not requery at all. What I am trying to achieve is to change the listbox's rowsource, as I said this works fine when the form footer is visible but then nothing happens when the form footers is invisible. I know the rowsource is changing in the listbox but it doesn't requery....
6
8004
by: MarkoBBC | last post by:
Hi everyone, First a brief description of my form: I have a subform within a main form. In my subform, I have a listbox displaying address information by firm name. A user first has to select a firm name in a combo box above the list box. The listbox and the combo box join on firm name. The listbox records what address was selected in the address table by the way of an address id number. I set up a macro to requery the listbox when you...
11
7194
by: mrowe | last post by:
I am using Access 2003. (I am also using ADO in the vast majority of my code. I recently read a post that indicated that ADO is not all that is was initially cracked up to be. In the back of my mind I am wonder if this is causing my problem, but I don’t want to go through the work to convert to DAO unless I know it is truly in my best interest.) I am having problems getting a requery to show up consistently on a couple of forms. I have...
2
1014
by: Lyn | last post by:
Hi, I am using a form (FormA) to list the records in a recordset. In the FormA footer, I have an "Add" command button that opens a new form (FormB) modally which is used to input and save a new record to the table on which the recordset is based. On closing FormB after inputting a new record, I would like to refresh/requery the listing in FormA automatically so that it includes the new record. I don't seem to be able to get this to...
0
9988
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11580
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
11354
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
8256
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7431
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6119
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6339
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4949
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4541
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.