473,698 Members | 2,033 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Unable to update combo box using list box selection - error 2115

6 New Member
I am trying to set the value of a combo box based on the selection of a list box. I have created a very simple generic form to try to achieve this goal, but without success. The form has a list box bound to a query, a button, and a combo box bound to another query. The queries for the list box and the combo box are independent. I can set the value of the combo box when the form loads (sub Form_Load) and when I click on the button (sub Command2_Click) , but when I make a selection in the list box (sub List5_AfterUpda te) I get Runtime error 2115: The Macro of function set to the BeforeUpdate or ValidationRule property for this field is preventing MS Access from saving the date in the field. I do not have any validation rules set and this is a complete listing of my code.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command2_Click()
  2.     Me.Combo0.SetFocus
  3.     Me.Combo0.ListIndex = 2
  4. End Sub
  5.  
  6. Private Sub Form_Load()
  7.     Me.Combo0.SetFocus
  8.     Me.Combo0.ListIndex = 0
  9. End Sub
  10.  
  11. Private Sub List5_AfterUpdate()
  12.     Me.Combo0.SetFocus
  13.     Me.Combo0.ListIndex = 3
  14. End Sub
  15.  
Nov 3 '11
11 4626
mcompagno
6 New Member
Success at last!
I had the answer all along in another part of my code.
Instead of using listindex I used itemdata:
Me.combo0= Me.combo0.ItemD ata(1)
This does the same thing as the setting the listindex from the point of view of the user, but does not throw the error.
Nov 9 '11 #11
sierra7
446 Recognized Expert Contributor
Glad you got it to work
S7
Nov 9 '11 #12

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

Similar topics

1
1164
by: Katie | last post by:
I am a rather inexperienced VBA programmer so this may be a very simple question! I need to update combo boxes using VBA to incorporate filters from other fields. I have been trying to use .RowSource, but I can't get it to work. Any advice? Could you email at above address! Katie
3
11097
by: Brian | last post by:
I have a form that has a textbox used to search records in a table. On the form I have a listbox which shows each record in the table. When you click on each row in the listbox the rest of the form updates to show the other fields in the table. The problem I am having is when I enter text to search the table the list narrows successfully, but the rest of the information still reflects the first record in the table. When I click on one of...
2
7168
by: sianan | last post by:
I am having a problem doing the following in generics. I have two list of a custom item type. I need to iterate through the first list and match each item against another list to see if there is a match. If a match is found, I need to move the matched item into another list. I want to compare the objects by value. The items in each list have an ID property (of type object) which I want to convert to a strng in order to be able to do...
3
3844
by: Cagey | last post by:
What I'm trying for: If this selection or if click on selection (highlighted line choice/ which ever selection change) w/in query's combo dropdown list box (on Switchboard), then Open in Datasheet View, the specific underlying record's Row... showing all columns Or selected columns. For a specific row's record ONLY, Or for all Xs (same type), or for the whole data sheet (all records... includes all types then), but focus still opens...
3
23245
by: keithsimpson3973 | last post by:
I have 6 combo boxes on a vb form. Is there a way, using vb6, to remove the list item that was selected in the first combo box from the list of the second, third fourth, fifth, and sixth combo box list? This is what I have tried with no luck cb = combobox1.listindex combobox2.list = combobox1.list combobox2.removeitem cb
2
2377
by: JweldonH | last post by:
My issue probably has a simple answer. I want to limit a populated combo box to items that are NOT in use in another table. I have a Table with a field that looks up values from another table via a combo box. As I select items from that combo box list, I would like for the list to automatically remove that selection from the combo box list so it wont be availble to select. (And have it add any item that I change or remove from the tabe) The...
1
1254
by: napstar | last post by:
I have 2 combo boxes which can be used to set an employee's availability and Salary type on an employees form in access. I have sub which changes availability to “Full time”, if the salary type is “Retainer” ;but when I do this I keep getting Error 2115 : The macro or function set to the BeforeUpdate or ValidationRule property for this field is preventing Microsoft Access from saving the data in the field Private Sub SalaryType_Click() ...
4
2587
by: lulu123 | last post by:
here's my problem 1) rowsource .RowSource = "select distinct , " & "from Projects " & " where =" & Me! I have the above code, and it works fine. however, i want to make the combo box in alphabetical order by . I tried to add "order by " after "me!". But it gives me error msg. Can someone tell me how can i do that. Thanks. 2) REfresh the combo box list after add a record.
8
3355
by: hollinshead | last post by:
Hi there i have bit of an issue. i haver this database that is purely used for searching records under certain criteria. This criteria is chosen by the user on a form using list boxes and combo boxes. So when the criteria is chosen the user selects a click command button and then the results are displayed on another form. I have successfully created the code for the combo boxes on the form.The list boxes are are the problem which are set to...
16
19125
by: rudivs | last post by:
I would like to do data validation in the BeforeUpdate procedure, but Access gives me a runtime error when I try to do this: An example of what I am trying to do is as follows: Private Sub Option_BeforeUpdate(Cancel As Integer) If Option = A Then Answer=MsgBox("Don't you mean B?",vbYesNo) If Answer = vbYes Then
0
8672
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, 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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
8890
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,...
0
8858
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7711
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6517
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
4614
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3038
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
2322
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1997
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.