Requery a subform
In my application I have a form let say "frmContacts". Record Source
[tblContacts], with Primary Key [ContactID].
In this form I have a subform "frmContactFunctions". Record Source
[tblContactFunctions], with Primary Key [ContactFunctionsID] and Foreign Key
The two forms are linked with Link Child Fields [ContactID] and Link Master
Starting from the form "frmContacts" (without closing it) I can start an
other form called "frmContactsEdit" to edit a contact and its functions.
When via form "frmContactsE...Requery SubForm
I have a subform that is filtered by a combo box on my main form. The combo
box allows the users to select a year and then all the records within that
year will appear on the subform. I have the default of my combo box set to
"Year(Date())" so when the form is opened it will already show the records
for the current year. I also have some textboxes on my main form the do some
calculations based on the records on my subform. The problem is that when I
open the form and there are records on the subform the calculation controls
will not calculate until I select a year in the combo...AfterUpdate/BeforeUpdate and SetFocus
I have some problems with the SetFocus command in a Userform with an
AfterUpdate or BeforeUpdate routine.
To make it clear to you, I made a very small Userform to demonstrate it. It
only contains 8 TextBoxes and this code:
Private Sub TextBox01_AfterUpdate()
Private Sub TextBox02_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean)
Private Sub TextBox03_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Private Sub TextBox04_Change()
I expected that in ...AfterUpdate
In the AfterUpdate code I had the detail back colour change if a check box
(tbc) = True. However if I tick the box now it turns the back colour of every
form irrespective if that record is ticked tbc or not!
Any help on solving this would be great.
Private Sub tbc_afterupdate()
If Me.tbc = True Then
Me.Section(0).BackColor = 65535
Me.Section(0).BackColor = 16777215
If you are using a continuous form, that code won't work. The good news is
that you can use Conditional Formatting to make it work. In Design View,
select the combo box and fro...AfterUpdate Question!
I want to add this to my code , Ony enter date if [DateCheck] (checkbox)
Any help would be great..............Thanks Bob
Private Sub tbAdditionCharge_AfterUpdate()
If tbDayNo.value = "" Or IsNull(tbDayNo.value) Then
tbDayNo.value = Format(Now, "dd-mmm-yy")
Me.tbDayNo=IIf(Me.DateCheck And IsNull(tbDayNo), _
"Bob V" <firstname.lastname@example.org> wrote in message
| I want to add this to my code , Ony enter date if [D...BeforeUpdate or AfterUpdate ?
I have an unbound form in which I have (amongst others) two comboboxes with
Although I present a combobox, limited to the choices to pick out, people
manage not to fill in those data and to jump via the TAB-key to the next
field. Of course I’ll have NULL value for this combobox, but how can I force
the user to look for the correct row ?
In the BeforeUpdate or in the AfterUpdate event ?
I have some code like :
Private Sub CboAfterUpdate()
if isnull(me.Cbo) then
Msgbox(“You must choose a value”)
But this does not se...Listbox requery
I have a listbox (lbProjects) that should enumerate all the Projects assigned
to a given Capital Request. The form (frmCER) is bound to the Capital Request
(tblCER) table, and its Primary Key is "CERID". The Project table
(tblProjects) has a foreign key in it called "CERID". I set up the listbox
initially unbound, with a record source that looked for all projects with a
CERID that matched forms!frmCER.CERID. It selected the first one just fine,
but as I scroll through the CERs, the listbox does not update. I coded the
OnChange event from the CERID field on the main f...Requerying
One of the fields of a table is sorted.
SELECT tblConfigGrupos.lintIndexKMaster, tblConfigGrupos.strNomeGrupo,
tblConfigGrupos.boolInactive, tblConfigGrupos.lintNGrupo FROM
tblConfigGrupos ORDER BY lintNGrupo;
If I change the content of one lintNGrupo field in one record, I
should issue a Me.Requery to sort it again so that the new sort is
To what event should I associate the command?
(Is this the right way to do it?)
Try the form's AfterUpdate event.
Doug Steele, Microsoft Access MVP
(no e-mails, please!)
"H. Martins&q...AfterUpdate Problem
I need to flash an "RE-ORDER ALERT" message after inventory level falls below
re-order level. The message only flashes up when I move to a next record
and back after a DoCmd.Save.
I need the message to flash immediate after a Save.
Note. The message is a flashing label on the form.
Perhaps you could code it to actually flash before DoCmd.Save is processed.
Once you're into that code string, it will be run.
Or, maybe consider a Message Box. I like this idea because it forces the
user to interact with the reorder message. No one can say "I didn'...AfterUpdate VB If statement
I am having a problem with this code:
Private Sub Cart_Shed_Number_AfterUpdate()
If (Me.Cart_Shed_Number) = "NA" And (Me.Cart_Type) = "NA" Then
Me.Cart_Shed_Fee = "0"
ElseIf (Me.Cart_Shed_Number) >= "A" And (Me.Cart_Type) = "Gas" Then
Me.Cart_Shed_Fee = "10"
ElseIf (Me.Cart_Shed_Number) >= "A" And (Me.Cart_Type) = "Electric" Then
Me.Cart_Shed_Fee = "20"
I want it to auto populate a "cart shed fee" field on a form depending on
the answers to the &q...Unbound combobox AfterUpdate
On some form I have several unbound combobox controls. Whenever some of them
is changed, I want:
1. reset the values for other combos on same form;
2. reset Filter and FilterOn properties for subform on same form;
3. reset Rowsource for a record locating combobox on this subform.
Currently I use combo's AfterUpdate's events for this - like here:
Private Sub Combo1_AfterUpdate()
Me.Combo2 = 0
Me.Combo3 = 0
If Nz(Me.Combo1, 0) = 0 Then
Me.MySubform.Form.Filter = ""
Me.MySubform.Form.FilterOn = False
Even when I set m_strFilter to a condition that does not exist, Requery()
still returns TRUE. To determine if a matching record was found, I'm using
IsBOF() and IsEOF() instead. This is acceptable, but I'm curious why
Requery() returns TRUE in such a situation. Maybe my definition of failure
is different from its.
set.m_strFilter = "[Date] BETWEEN ? AND ?";
set.m_Date1Param = CTime(2004, 1, 9, 0, 0, 0);
set.m_Date2Param = CTime(2004, 1, 9, 23, 59, 59);
if (set.Requery() != FALSE)
TRACE("%d, %d\n", set.IsBOF(), set.IsEOF());
set.Delete(); /...blinking form afterupdate
When i use this command:
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70
The form blinks with every update. Is there a way to prevent the form from
I hope to hear from you !
Best regards and thanks in advance,
This code requeries the form and displays any changes to the data.
Where are you using that code - is it on a button or some other event?
Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
"Pierkes" <email@example.com> wrote in message
> Hi...AfterUpdate Requery
I'm having a problem with Requery. I have 7 combo boxes that are cascading.
One gets it's data from the previous one. The first three requery and blank
out the combo boxes if the item that was selected isn't in the new list.
Although the last four do requery and get a new list, they keep the previous
selected text even if it isn't in the new list. I set the Limit To List
option but that didn't have an effect on the last four combo boxes. I posted
the different ways I've tried requerying below. The only one that seems to
remove the data is DoCmd.Requery but on...AfterUpdate Form Event Fires Repeatedly
I've been having this problem for a few months with a db I'm working on. I
know there must be something simple I'm overlooking, so I'd greatly
appreciate any help in identifying what the problem is.
I'm using the following to create a timestamp:
Me.dbLastUpdateUser = Forms!frmUserInfoHIDDEN!txtUserName
Me.dbLastUpdate = Now()
frmuserInfoHIDDEN refers to a form that is hidden on startup that stores the
name the user logged in with. This feature works fine.
The AfterUpdate timestamp used to work as well. However, now it repeatedly
fires and forces the user to stay on ...Triggering AfterUpdate Event
I have a data entry form using forms and multipages with numerous dat
fields for the user to populate. I have also written error handlers t
restrict the input of the user using the AfterUpdate event (e.g. I
they enter an invalid entry for a date field and move off, th
AfterUpdate triggers an error message, which pops up next to th
The general usage of this is that someone will open a new form, ente
data, and write to a worksheet. Since I do not allow invalid data to b
written, I can ensure that the data is correct when it is written, s
when I open the form, I do not need to validate ...AfterUpdate event procedure
I have an AfterUpdate procedure that populates values from a subform into
fields on my main data entry form. The forms/subforms were created using
Access 2000 and worked correctly in Access 2003. When I upgraded to Access
2007, the code no longer works....unless I enter the STUDYID value twice.
Any ideas as to why this is occurring? And how do I fix it?
Private Sub STUDYID_AfterUpdate()
[LNAME] = [frmsubIsol07].Form![Lname2]
[MI] = [frmsubIsol07].Form![MI2]
[FNAME] = [frmsubIsol07].Form![Fname2]
[COUNTY] = [frmsubIsol07].Form![County2]
[HOSPID] = [frmsubIsol07].Form![Ho...Repeat afterupdate code
I have a form that has about 25 inputs for data. I then have about 15 boxes
that I just calculate some numbers so people can see what the effects are as
they enter it. So for every data entry point I have the code behind
Private Sub Start_number_AfterUpdate()
Private sub Calculations()
Is there a way to have the calculation boxes all update after any of the
data entry points have without have to put in the afterupdate behind each
one? It works fine the way it is right now but I would like to clean it ...AfterUpdate Now() to table
I am using:
CurrentDb.Execute "UPDATE tbl_Projects SET DateUpdated = Now()"
as suggested here, but it is updating ALL records, how do I specify the
record that was actully changed?
If you are talking about TimeStamping a record that was updated on a form
then you want your code in the BeforeUpdate event of the form. In this case
you do not need SQL but simply:
[DateUpdated] = Now
>I am using:
>CurrentDb.Execute "UPDATE tbl_Projects SET DateUpdated = Now()"
>as suggested here, but it is updating ALL records, how do I specify the
>record that w...AfterUpdate Event for TextBox
I have this code for the afterupdate event on a text box that has data in it.
Me.Text732 = Replace(Abs(Val([Text732])), ".", "")
When I past this data 0000272400123456 into the text box, it gets rid of the
0000, becomes 272400123456
But if I past this kind of number 4223697600059898, it turns it into this
If I take the coding away and past the 4223697600059898 number, it stays the
same and doesn't get changed to the +15.
Any suggestions or changes to code to fix this?
if its a text field then it shouldnt be modifying any v...Can't Requery Combo Box on Subform
I wrote some code that executes on Not in List for a combo box. It opens a
form (dialog mode) that allows me to enter new data into the table that
provides data for the combo box. The last thing that happens is a requery on
the combo box.
This all works fine for combo boxes on a simple form. It doesn't work with
a combo box on a sub form. When I try it, I get "Index or primary key can't
contain a null value" after closing the dialog. The combo box doesn't
contain the new data; however, if I manually go to the menu bar and do a
Records-Refresh the data shows...Checkbox Click (and Afterupdate?)
I have a form with multiple checkboxes in the following format:
_X_ New England _X_ State1 _X_ State2 ...
_X_ Mid Atlantic _X_ State5 _X_ State6 ...
Using the following code in the On Click Event I was able to select all the
states in each row (i.e. all the states in New England):
If (Me."New England") Then
Me.State1 = True
Me.State2 = True
Me.State1 = False
Me.State2 = False
I thought that if I were to apply the same principle to the "Northeast"
If (Me."Northeast") Then
Me."New Engla...AfterUpdate event not firing?
I have a form which opens up a subform. On subform, there is a tab control
which has five tabs on it. Each tab contains a sub-form on it. I have a combo
box on one of these sub-forms to which I am attempting to add in
functionality to implement a recent entries list. I have the following code
added to this sub-form's control's AfterUpdate event. However, this event
does not fire after the field is updated. I have verified this by inserting
breakpoints in the code, and the breakpoint never fires either.
Any idea why the AfterUpdate event is not firing? Any input would be great.
I have a form that when opened asks for a patient's NHS number as criteria
for the underlying query. The main form then gives the 'personal'
information, and a subform displays all entries for that person. However, I
can't work out how to requery the original form/query to call up another
patient without closing and reopening so that it asks me for the criteria
Is this possible? Is it something simple that I'm missing?!
I assume you have a control that the user will use to go to another record
(like a button on the...Afterupdate Code Question
I am using the following code to disable the date field if the yes/no box is
null or false:
Private Sub Combo33_AfterUpdate()
Me.Ctl1st_Date.Enabled = Nz(Me.Combo33, False)
Me.Most_Recent_Date.Enabled = Nz(Me.Combo33, False)
What can i place in this code so that it also deletes whatever date was in
this field if it is selected as N or False? Any help is appreciated. Do I
also need to place this in the beforeupdate of the form?
Nevermind I just added:
If Me.Combo33 = False Then
Me.Ctl1st_Date = Null
Me.Most_Recent_Date = Null
And it works fine