Dear users and experts,
An unbound combo box in my form is responsible for changing a city name for an update query that creates a temprorary table which the form uses as its record source.
In case that table is already created, and the combo box value is to be changed again, the temp. table needs to be deleted and the form needs to be requeried. I use on before update event of the combo box: - Private Sub citylist_BeforeUpdate(Cancel As Integer)
-
If DCount("CusId", "tblTempDist") > 0 Then
-
If MsgBox("This will reset the temprorary list, continue?", vbExclamation + vbOKCancel _
-
, strProjectTitle) = vbCancel Then
-
Cancel = True
-
DoCmd.CancelEvent
-
SendKeys "{ESC}", False
-
Exit Sub
-
Else
-
'user agrees to reset
-
Cancel = False
-
-
DoCmd.RunSQL " delete * from tblTempDist; "
-
-
Me.Requery ' here the error appears
-
-
Exit Sub
-
End If
-
Else
-
Cancel = False
-
End If
-
End Sub
Changing citylist combo box value returns the following error on Me.Requery line: Run-time Error '2115': The macro or function set to the BeforeUpdate or ValidationRule propery for this field is preventing database1 from saving the data in the field.
Replacing Me.Requery with Me.cusId.SetFoc us returns the following error: Run-time error '2108': You must save the field before you execute the GoToControl action, the GoToControl method, or the SetFocus method
I don't understand the underling problem of this error, what am I doing wrong and how to solve this.
Need your help.
Thanks,
Michael.
8 4088 NeoPa 32,564
Recognized Expert Moderator MVP
You are requerying the form when you want to requery just the ComboBox.
Try changing that line to :
You are requerying the form when you want to requery just the ComboBox.
Try changing that line to :
Well, it returns the same mistake as with form requery...
The funny thing is, that it only returns that mistake on BeforeUpdate event. If I requery afterwards in a seprate command , requery works
NeoPa 32,564
Recognized Expert Moderator MVP
Try putting that one line in the AfterUpdate event procedure then.
It won't do any harm - even if it wasn't necessary (but you can make it work only in the same circumstances with code if you really want to).
It may be because it won't allow a requery of a field from within the BeforeUpdate of that same field for reasons of data integrity.
Try putting that one line in the AfterUpdate event procedure then.
It won't do any harm - even if it wasn't necessary (but you can make it work only in the same circumstances with code if you really want to).
It may be because it won't allow a requery of a field from within the BeforeUpdate of that same field for reasons of data integrity.
Of course! The AfterUpdate event! I should've think of that!
Thanks :)
NeoPa 32,564
Recognized Expert Moderator MVP
Of course! The AfterUpdate event! I should've think of that!
Thanks :)
It wasn't so obvious.
The BeforeUpdate event was correct for what you were doing, it's just that it can't allow you to change an item while you're still determining whether the proposed change to that same item should be allowed. If it didn't protect you from doing that it could really get its knickers in a twist.
The BeforeUpdate event was correct for what you were doing, it's just that it can't allow you to change an item while you're still determining whether the proposed change to that same item should be allowed.
But in the BeforeUpdate event I was trying to change not the combo-box, but the form's underlying table which is updated based on the combo-box value. The combo-box is unbound.
Still, the change/update of the underlying table was possible only on the AfterUpdate event.
Regards.
NeoPa 32,564
Recognized Expert Moderator MVP
That wasn't the version I was working on.
I was under the impression that you had applied the change I suggested in post #2.
Not that it's important now I suppose.
Glad you've got it sorted anyway :)
That wasn't the version I was working on.
I was under the impression that you had applied the change I suggested in post #2.
Not that it's important now I suppose.
Glad you've got it sorted anyway :)
Thanks for you openhandness :)
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Scott |
last post by:
I have created a form that has a few combo boxes on it. On the form I
have ComboBoxA which selects data from a region, and ComboBoxB that
selects individual locations within a selected region. I need to
figure out the correct way to Requery ComboBoxA after I have updated
it. I searched the archive for this list and found a simple solution:...
|
by: P |
last post by:
Hi,
I have a form with several controls. One of them is initialized through VB
in frm_current. I am using the frm_beforeupdate event to prompt users for
saving changes. How can I make it so that the initialization of the control
does not dirty the form? I don't want to prompt the users for saving changes
unless he changed one of the remaing...
|
by: DebbieG |
last post by:
I have a form based on this query:
SELECT Students.LastSerDT, OtherInfo.Served, OtherInfo.HSGradYr,
OtherInfo.ActivePart, OtherInfo.Served, Students.SSN, & ", " &
& " " & AS Name, Students.LastNM, Students.FirstNM,
Students.MI, Students.DOB, Students.GenderCD, Students.EthnicityCD,
Students.EligibilityCD, Students.UBInitiative,...
|
by: Sean |
last post by:
Greetings all,
I am attempting to make a form that will filter through several tables
that
(I believe) have refretial integrity. I am pulling data from several
tables into the form and i would like to eventually be able to filter
down through the
tables untill i can reach one unique record. I am creating a datbase
to keep track of...
|
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...
| |
by: Zlatko Matiæ |
last post by:
There is a form (single form) and a combobox. I want that current record of
the form is adjusted according to selected value in the combobox. Cuurrent
record should be the same as the value in the combobox.
What is the solution?
Thank you in advance.
|
by: Robert |
last post by:
I borrowed one of the forms from the MS Access Solutions database and
altered it to fit my needs. The form was the 'EditProducts' form where you
select a category from a combo which then populates another combo for
products. Then when you select a product, the form displays the info for it.
Everything is working well except, with the original,...
|
by: Robert |
last post by:
Every thing worked fine until all of a sudden, I get the following error
whenever I try to do anything on one of my forms that calls an Event
Procedure. I get the error as soon as the form opens because I have an
OnLoad event. If I take that out the form will open but I will get the same
error if I attempt anything else that will call and...
|
by: Macbane |
last post by:
Hi,
I have a 'main' form called frmIssues which has a subform control
(named linkIssuesDrug) containing the subform sfrmLink_Issues_Drugs.
A control button on the main form opens a pop-up form which allows me
to edit the record in the subform. What I want to happen is for
subform with the new edits to be updated on the main form when I...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
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...
| |
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. ...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
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...
|
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...
|
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...
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |