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

Trouble with form requery that has been modified on beforeupdate combo box event

176 100+
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:

Expand|Select|Wrap|Line Numbers
  1. Private Sub citylist_BeforeUpdate(Cancel As Integer)
  2.     If DCount("CusId", "tblTempDist") > 0 Then
  3.         If MsgBox("This will reset the temprorary list, continue?", vbExclamation + vbOKCancel  _
  4.             , strProjectTitle) = vbCancel Then
  5.             Cancel = True
  6.             DoCmd.CancelEvent
  7.             SendKeys "{ESC}", False
  8.             Exit Sub
  9.         Else
  10.             'user agrees to reset
  11.             Cancel = False
  12.  
  13.             DoCmd.RunSQL " delete * from tblTempDist; "
  14.  
  15.             Me.Requery      ' here the error appears
  16.  
  17.             Exit Sub
  18.         End If
  19.     Else
  20.         Cancel = False
  21.     End If
  22. 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.SetFocus 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.
Feb 9 '07 #1
8 4069
NeoPa
32,556 Expert Mod 16PB
You are requerying the form when you want to requery just the ComboBox.
Try changing that line to :
Expand|Select|Wrap|Line Numbers
  1.             Call Me!citylist.Requery
Feb 10 '07 #2
Michael R
176 100+
You are requerying the form when you want to requery just the ComboBox.
Try changing that line to :
Expand|Select|Wrap|Line Numbers
  1.             Call Me!citylist.Requery
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
Feb 11 '07 #3
NeoPa
32,556 Expert Mod 16PB
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.
Feb 11 '07 #4
Michael R
176 100+
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 :)
Feb 11 '07 #5
NeoPa
32,556 Expert Mod 16PB
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.
Feb 11 '07 #6
Michael R
176 100+
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.
Feb 11 '07 #7
NeoPa
32,556 Expert Mod 16PB
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 :)
Feb 11 '07 #8
Michael R
176 100+
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 :)
Feb 11 '07 #9

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

Similar topics

5
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...
6
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...
4
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,...
2
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...
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...
8
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...
1
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...
1
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...
4
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...
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: 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
marktang
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,...
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,...
0
jinu1996
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...
0
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...

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.