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

Requery problem

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 3675
MMcCarthy
14,534 Expert Mod 8TB
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!MainFormName!SubFormName.Form.Requery
Oct 30 '06 #2
ebs57
18
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
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...
6
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...
4
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...
20
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
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",...
2
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...
1
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...
6
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...
11
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...
2
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...
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: 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
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...

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.