473,386 Members | 1,598 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.

Run-time error 2115?

675 512MB
I have a listbox named lbxSelect which has RowSource = strSQL set in VBA code. This displays correctly on my form (fAAA).

Once displayed, I want to use it to select a record, and display the selected record on the form (View=SingleForm).

Whether I use the Mouse to click in lbxSelect, a command button (cmdFirst, cmdNext, etc), or within VBA, I call the same subroutine to set iixFormKey, a global long variable.

I then call a subroutine to display the form, with the statement
Expand|Select|Wrap|Line Numbers
  1. Forms!fAAA.Filter = "Key=" & iixFormKey
This statement works correctly the first time. When strSQL is assigned to RowSource, I then call from VBA the subroutine to set iixFormKey to the first row, and display the form. It displays correctly.

When I attempt to change lbxSelect.RowSource and select the first row with VBA, it fails with:
2115 The macro or function set to the BeforeUpdate or ValidationRule property for this field is preventing Microsoft Office Access from saving the data in the field.
Removing the VBA code to select row 1, and using the "First" command button does not get an error.

What is going on?
Jul 6 '09 #1
18 8427
ChipR
1,287 Expert 1GB
Is the line of code you displayed the one where the error occurs?
Jul 6 '09 #2
OldBirdman
675 512MB
Yes!

I've Googled this to death. Can't seem to get any ideas here. Why/what would be being updated if I don't change anything. I've been thru all my tables, and made sure all Required have entries, etc. I don't use Access Validation field in this program.

The program has no messages when Debug->Compile, and I've tried Tools->Database Utilities->Compact and Repair Database. Same results Windows XP & Vista.
Jul 6 '09 #3
ChipR
1,287 Expert 1GB
Do any fields on your form have default values? Could you give an example of strSQL?
Jul 6 '09 #4
ChipR
1,287 Expert 1GB
I guess what I meant to ask was whether lbxSelect was unbound. strSQL shouldn't matter then.
Jul 6 '09 #5
OldBirdman
675 512MB
Yes, some fields have default values. I don't think that is the problem, because I can't easily answer your second request, and show sample value for strSQL.

ALL "filtering" is done here. The filter form is quite complex, with 12 tabs for 15 different fields. Also are a couple of checkboxes and listboxes unbound on the form itself to further filter what is displayed in lbxSelect. Changing these, and clicking "Create Filter" in the filter form builds a new strSQL. Changing a "Filter" field on the form causes an immediate rebuild and requery of lbxSelect. Nobody wants to debug that, except me.

So I created a very simple string as an illustration. I actually replaced the line of code:
Expand|Select|Wrap|Line Numbers
  1. Forms!fAAA.lbxSelect.RowSource = strSQL
with:
Expand|Select|Wrap|Line Numbers
  1. Forms!fAAA.lbxSelect.RowSource = _
  2.    "SELECT Key, TitleName, FirstLetter " & _
  3.    "FROM tAAA " & _
  4.    "WHERE (((FirstLetter)='N')) " & _
  5.    "ORDER BY TitleName;"
The problems go away. Bingo! So there is something in the query that is wrong. I can start adding complexity to the constant string in my code until it fails, as one approach.
Jul 6 '09 #6
OldBirdman
675 512MB
In my attempt to simplify and test, I removed too much, and my project seemed to work. It didn't.

I have stripped this project to an absolute minimum, and still cannot figure out what is happening.

Expand|Select|Wrap|Line Numbers
  1. Table (tAAA)
  2.   Key (PK) AutoNumber
  3. Table (tTitles)
  4.   Key (PK) AutoNumber
  5.   ptr->tAAA (FK) Number(Long Integer)
  6.   Title Text(255) Indexed Yes (Duplicates OK) DefaultValue = ""  Required No
  7.  
  8. Form (fAAA) .RecordSource = tAAA
  9.   lbxAlpha Unbound ListBox .RowSource (*;A;C;E)
  10.   lbxSelect Unbound ListBox .RowSource assigned in VBA code
  11.   txtTitleName Unbound TextBox .Value assigned in VBA code
  12.   txtKey Bound/Unbound (I have tried both) Textbox
  13.  
The code has been ALL moved to the form class module. It is:
Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3.  
  4. 'Select Variables
  5. Dim iixSelectCount As Long
  6. Dim iixSelectedRow As Long
  7.  
  8. 'Form Data Variables
  9. Dim iixFormKey As Long
  10.  
  11.  
  12.  
  13.  
  14. Private Sub lbxAlpha_Click()
  15.     Call QuerySelect(lbxAlpha)
  16. End Sub 'lbxAlpha_Click
  17.  
  18. Private Sub lbxSelect_Click()
  19.     Call SelectOneTitle
  20. End Sub 'lbxSelect_Click
  21.  
  22.  
  23.  
  24. Private Sub Form_Load()
  25. 'Initialize Form Controls & Properties
  26.     If Key.ControlSource = "" Then
  27.         lblKey.Caption = "Key (UnBound && Blank)"
  28.     Else
  29.         lblKey.Caption = "Key (Bound Showing Key)"
  30.     End If
  31.  
  32.     Me.FilterOn = True
  33.  
  34. 'Initialize Global Variables
  35.     'Form Data Variables
  36.     iixFormKey = 0
  37.  
  38.     'Select Variables
  39.     Call QuerySelect("*") 'This will initialize all Select Variables and lbxSelect
  40.  
  41. End Sub 'Form_Load
  42.  
  43.  
  44.  
  45. Public Sub QuerySelect(strLetter As String)
  46. Dim strSELECT As String
  47. Dim strFROM As String
  48. Dim strWHERE As String
  49. Dim strORDERBY As String
  50. Dim strSQL As String
  51.  
  52.     'SELECT Clause
  53.     strSELECT = "SELECT [ptr->tAAA], Title "
  54.  
  55.     'FROM Clause
  56.     strFROM = "FROM tTitles "
  57.  
  58.     'WHERE Clause
  59.     Select Case strLetter
  60.     Case "*"
  61.         strWHERE = ""
  62.     Case Else
  63.         strWHERE = "WHERE Title LIKE """ & strLetter & "*"" "
  64.     End Select
  65.  
  66.     'ORDERBY Clause
  67.     strORDERBY = "ORDER BY Title;"
  68.  
  69.     strSQL = strSELECT & strFROM & strWHERE & strORDERBY
  70.     lbxSelect.RowSource = strSQL
  71.     iixSelectCount = lbxSelect.ListCount
  72.  
  73.     lbxSelect.Selected(0) = True
  74.     Call SelectOneTitle
  75. End Sub 'QuerySelect
  76.  
  77.  
  78. Public Sub SelectOneTitle()
  79.     iixSelectedRow = lbxSelect.ListIndex     'Save selected Row
  80.     iixFormKey = lbxSelect.Column(0)         'Save selected Key
  81.     txtTitleName = iixFormKey & " " & lbxSelect.Column(1)
  82.     Filter = "Key=" & iixFormKey
  83. End Sub 'SelectOneTitle
  84.  
The error occurs on Line 82.
Run-time error '2115':
The macro or function set to the BeforeUpdate or ValidationRule property for this field is preventing Microsoft Office Access from saving the data in the field.
Line 81 works, and the data is valid for lbxSelect. lbxSelect is Unbound, and is already requeried by the time the error occurs. It displays correctly.

Summary of what this is supposed to do:
1) User selects a letter (or *=ALL) in lbxAlpha - This test only has *;A;C;E
2) lbxSelect displays all Titles/Names for that letter
3) The first displayed Title is highlighted, and the data displayed on the form
4) User can select another Title
4a) Form displays data for new choice
Jul 7 '09 #7
ChipR
1,287 Expert 1GB
In my code, trying to use Filter rather than Me.Filter didn't produce an error, it just didn't do anything.
Jul 8 '09 #8
OldBirdman
675 512MB
Thanks ChipR for taking the time to actually try the code. Whether Me.Filter=, Forms!fAAA.Filter=, or just Filter=strSQL, I get the same error.

When you ran this with the Me.Filter, what happened?

In my actual project, the 2 subroutines will have to be in an external module. SelectOneTitle will be called from the OnClick of navagation buttons, some on a subForm. QuerySelect will also be moved to the external module for similar reasons. This will actually require the Forms!fAAA.Filter method. So I need to make that work.
Jul 8 '09 #9
OldBirdman
675 512MB
Removing Line 82 of the code, to avoid the error, produces a different kind of error. lbxSelect becomes "Locked" after the requery, It can be requeried, but a row cannot be selected with the mouse.
Jul 8 '09 #10
OldBirdman
675 512MB
Access 2003 Windows Vista
I've stripped my program to do less than I need it to do, and I still cannot get it to run correctly. Again, I started from scratch. Did complete Virus Scan, nothing found. Rebooted, started Access, new project.
Entered EVERYTHING from scratch, including typing all VBA code from keyboard, no cut/paste from any other source.

Expand|Select|Wrap|Line Numbers
  1. Table = tNames
  2. Key PK Autonum
  3. Name Text All properties default
  4.  
  5. Key   Name
  6.  1    A 222
  7.  2    B 111
  8.  3    C 333
  9.  4    C 111
  10.  5    B 333
  11.  6    B 222
  12.  7    A 333
  13.  8    A 111
  14.  9    C 222
  15.  
  16. Form = fAAA
  17. Default View = Single Form
  18. Everything else is default when form created in Design View
  19.  
  20. lbxSelect  ListBox Created with Wizard
  21. Column Count = 2
  22. Column Widths = 0";1";
  23. Row Source Type = Table/Query
  24. Row Source =
  25. Bound Column = 1
  26. Enabled = Yes
  27. Locked = No
  28.  
  29. lbxAlpha  ListBox Created with Wizard
  30. Column Count = 1
  31. Column Widths = 1";
  32. Row Source Type = Value List
  33. Row Source = "A";"B";"C"
  34. Bound Column = 1
  35. Enabled = Yes
  36. Locked = No
This form has 2 controls. Neither is bound to a field in the table tNames. The form inself is bound to that table. No other controls except Navigation Controls inserted at bottom by Access Wizard.

I only have 8 lines of actual code, plus the overhead of subroutines ...Sub....EndSub. That code is:
Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3.  
  4. Private Sub lbxAlpha_Click()
  5.     Call QuerySelect(lbxAlpha)
  6. End Sub 'lbxAlpha_Click
  7.  
  8. Private Sub Form_Load()
  9.     Me.FilterOn = True
  10.     lbxSelect.RowSource = _
  11.             "SELECT Key, Name FROM tNames ORDER BY Name;"
  12.     lbxSelect.Selected(0) = True    'Select the first row of ListBox
  13. End Sub 'Form_Load
  14.  
  15. Sub QuerySelect(strLetter As String)
  16.     lbxSelect.RowSource = "SELECT Key, Name " & _
  17.             "FROM tNames " & _
  18.             "WHERE Name LIKE """ & strLetter & "*"" " & _
  19.             "ORDER BY Name;"
  20.     lbxSelect.Selected(0) = True    'Select the first row of ListBox
  21.     Filter = "Key=" & lbxSelect.Column(0)
  22. End Sub 'QuerySelect
  23.  
  24. Private Sub lbxSelect_Click()
  25.     Filter = "Key=" & lbxSelect.Column(0)
  26. End Sub 'lbxSelect_Click

Issues:
1) Line 12 triggers OnClick and code goes to Line 25
2) Line 20 does not trigger OnClick and code continues sequentially
3) Click lbxAlpha "B"
Click lbxSelect "B 222"
Click lbxAlpha "C"
lbxSelect now locked

If I make the following changes:
Expand|Select|Wrap|Line Numbers
  1. Control (lbxSelect)  Bound Column = 0
  2. Line 12 and Line 20    lbxSelect = 0
then issues 1 & 3 go away. Program now works.

I need to know what is going on here!
Jul 9 '09 #11
ChipR
1,287 Expert 1GB
lbxSelect should not be bound to column 1 because that would be the Name field. When you select C in step 3 and filter the form, lbxSelect is still bound to B. That may be why it gets locked. Setting the bound column to 0 should resolve that issue.
I would not expect line 20 to trigger a call to lbxSelect_Click(), but I haven't tested.
Jul 10 '09 #12
OldBirdman
675 512MB
lbxSelect should not be bound to column 1 because that would be the Name field.
In the properties form, Column 1 is the first, or leftmost, column. It is not zero-based. Therefore, the bound column is Key.

When you select C in step 3 and filter the form, lbxSelect is still bound to B.
I select "C" in a listbox which changes the selected row, and therefore the value, from "B" to "C". I then requery lbxSelect. These two listboxes are not linked to each other. An event in lbxAlpha requeries lbxSelect. lbxSelect now correctly displays those Names starting with "C". There is no reason this control should now be locked.

Can you elaborate some more?
Jul 10 '09 #13
ChipR
1,287 Expert 1GB
I've neglected to actually test it. I'll try it out and get back to you.
Jul 10 '09 #14
OldBirdman
675 512MB
I'm posting the version of this program as last described (Post #11).

This should allow you to test easily.

Thank you for doing this for me, as I am ABSOLUTELY stumped by this.
Attached Files
File Type: zip ListBox.zip (11.6 KB, 132 views)
Jul 10 '09 #15
ChipR
1,287 Expert 1GB
I actually recreated it from scratch, and typed in my own code. The only difference I see is that I didn't use the keyword Name for a field name, and I had to use Me.FilterOn = True after each Me.Filter or it didn't set the filter. I couldn't recreate the locking of the list box. I'm in Access 2007 on XP though.
Jul 10 '09 #16
OldBirdman
675 512MB
I'm in XP, but Access 2003.

I have no controls on the form that actually show whether the correct record would be displayed or not. All I know is that the Access Navagation Control shows I am on Record 1 of 1 (Filtered), so I presume it is filtering to a single record.

This code is the 'essence' of what I want to do. I I can't debug these 8 lines of code, I can't move forward. That is why I want to know what is going on. Adding more controls or code gets me the Run-time error '2115'.

I posted the code and sample table in my previous post.
Jul 10 '09 #17
ChipR
1,287 Expert 1GB
Took a look at your .zip and I didn't get any errors or locking. The form in the Sratch.mdb wasn't bound to the recordset, but once I set it, I was able to put 2 text boxes on the form and observe that the recordset wasn't filtering. I don't have 2003 anymore, but I think plenty of people here do. Maybe someone else can test your example.
Jul 10 '09 #18
OldBirdman
675 512MB
Interesting, because when I put a bound control on the form, it filters just fine, the first time. After that, I get error '2115'. Adding FilterOn = True before or after the Filter = statement has no effect. It is already on before the Filter statement, and too late afterwards.

Thanks for all your time and effort
Jul 10 '09 #19

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

Similar topics

3
by: leroybt.rm | last post by:
Can someone tell me how to run a script from a interactive shell I type the following: >>>python filename >>>python filename.py >>>run filename >>>run filename.py >>>/run filename >>>/run...
4
by: Ed | last post by:
Hello, I took a course in asp about 2 years ago and I was practicing with IIS 5.0. Then I put it down for a while. Now trying to get back to it. I can't run asp files from subdirectories of...
6
by: orekin | last post by:
Hi There I have been trying to come to grips with Application.Run(), Application.Exit() and the Message Pump and I would really appreciate some feedback on the following questions .. There are...
13
by: Bob Day | last post by:
Using vs2003, vb.net I start a thread, giving it a name before start. Code snippet: 'give each thread a unique name (for later identification) Trunk_Thread.Name = "Trunk_0_Thread" ' allow...
19
by: Bryan | last post by:
How can i run a bit of code straight from the IDE? Right now i make a temporary button and put the code behind that, then i run debug mode and click on the button. Is there a way to highlight...
9
by: Brett Wesoloski | last post by:
I am new to VS2005. I changed my program.cs file to be a different form I am working on. But when I go to run the application it still brings up the form that was originally declared as new. ...
7
by: Lee Crabtree | last post by:
I remember when I was first getting into .NET Forms programming that there was a rather emphatic rule about not constructing a form before calling Application.Run with it. So this: ...
8
by: David Thielen | last post by:
Hi; In our setup program how do I determine if I need to run "aspnet_regiis –i" and if so, is there an API I can calll rather than finding that program on the user's disk and calling it? --...
3
by: traceable1 | last post by:
Is there a way I can set up a SQL script to run when the instance starts up? SQL Server 2005 SP2 thanks!
7
by: mxdevit | last post by:
Task: run application from ASP.NET for example, you have a button on ASP.NET page, when press this button - one application is invoked. the code to run application (for example, notepad) is...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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
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
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,...
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...

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.