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

Why not to change the datatype of standard procedures

Knut Ole
I have a form, Query18, in which I have these comboboxes... thing is, I have had it working fine for long, then suddenly! I get this errors... (for all comboboxes, basically all the code i'd put so far in the form...)

there are no superfluent subs or ifs... when i access the vba from the control property event handler, i am brought correctly to the right code-piece. when it's run, however, i get the error...

i so hope this is not a bug!? any help greatly appreciated! thank you..
Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2.  
  3. Private Sub Combo333_BeforeUpdate(Cancel As Integer)
  4.  
  5. End Sub
  6.  
  7. Private Sub Combo336_KeyDown(KeyCode As Integer, Shift As Integer)
  8. 'Form_Query18.Combo336.Dropdown
  9. End Sub
  10.  
  11. Private Sub Combo336_NotInList(NewData As String, Response As Integer)
  12.  
  13. Dim strMsg As String
  14. Dim MyDB As DAO.Database
  15. Dim rstNewContact As DAO.Recordset
  16.  
  17. strMsg = "'" & NewData & "' is not in the list.  "
  18. strMsg = strMsg & "Would you like to add a New Customer?"
  19.  
  20. If vbNo = MsgBox(strMsg, vbYesNo + vbQuestion, "New Customer") Then
  21.   Response = acDataErrDisplay 'Access displays its standard Error Message
  22. Else
  23.   'Decided to Add the New Customer
  24.   Set MyDB = CurrentDb
  25.   Set rstNewContact = MyDB.OpenRecordset("Contacts", dbOpenDynaset)
  26.     rstNewContact.AddNew
  27.       rstNewContact("LastName") = NewData
  28.     rstNewContact.Update
  29.  
  30.     Response = acDataErrAdded   'Item added to underlying Recordset and the Combo
  31.                                 'Box is Requeried, Item added to List
  32.     rstNewContact.Close
  33.     Set rstNewContact = Nothing
  34. End If
  35. bolNewRec = True
  36.  
  37. End Sub
  38.  
  39. Private Sub Combo340_KeyDown(KeyCode As Integer, Shift As Integer)
  40. If bolNewRec = True Then
  41.     Form_Query18.Combo340.AutoExpand = False
  42.  
  43. Else
  44.     Form_Query18.Combo340.Dropdown
  45. End If
  46. End Sub
  47.  
  48. Private Sub Combo340_NotInList(NewData As String, Response As Integer)
  49.  
  50. Dim strMsg As String
  51. Dim MyDB As DAO.Database
  52. Dim rstNewContact As DAO.Recordset
  53.  
  54. strMsg = "'" & NewData & "' is not in the list.  "
  55. strMsg = strMsg & "Would you like to add a New Customer?"
  56.  
  57. If vbNo = MsgBox(strMsg, vbYesNo + vbQuestion, "New Customer") Then
  58.   Response = acDataErrDisplay 'Access displays its standard Error Message
  59. Else
  60.   'Decided to Add the New Customer
  61.   Set MyDB = CurrentDb
  62.   Set rstNewContact = MyDB.OpenRecordset("Contacts", dbOpenDynaset)
  63.     rstNewContact.MoveLast
  64.     rstNewContact.Edit
  65.     rstNewContact("FirstName") = NewData
  66.     rstNewContact.Update
  67.  
  68.     Response = acDataErrAdded   'Item added to underlying Recordset and the Combo
  69.                                 'Box is Requeried, Item added to List
  70.     rstNewContact.Close
  71.     Set rstNewContact = Nothing
  72. End If
  73.  
  74.     Response = acDataErrAdded
  75. End Sub
  76.  
  77. Private Sub Mobile_KeyDown(KeyCode As Integer, Shift As Integer)
  78. If bolNewRec = True Then
  79.     Form_Query18.Mobile.AutoExpand = False
  80.  
  81. Else
  82.     Form_Query18.Mobile.Dropdown
  83. End If
  84. End Sub
  85.  
  86. Private Sub Mobile_NotInList(NewData As Integer, Response As Integer)
  87. Dim strMsg As String
  88. Dim MyDB As DAO.Database
  89. Dim rstNewContact As DAO.Recordset
  90.  
  91. strMsg = "'" & NewData & "' is not in the list.  "
  92. strMsg = strMsg & "Would you like to add a New Customer?"
  93.  
  94. If vbNo = MsgBox(strMsg, vbYesNo + vbQuestion, "New Customer") Then
  95.   Response = acDataErrDisplay 'Access displays its standard Error Message
  96. Else
  97.   'Decided to Add the New Customer
  98.   Set MyDB = CurrentDb
  99.   Set rstNewContact = MyDB.OpenRecordset("Contacts", dbOpenDynaset)
  100.     rstNewContact.MoveLast
  101.     rstNewContact.Edit
  102.     rstNewContact("Mobile") = NewData
  103.     rstNewContact.Update
  104.  
  105.     Response = acDataErrAdded   'Item added to underlying Recordset and the Combo
  106.                                 'Box is Requeried, Item added to List
  107.     rstNewContact.Close
  108.     Set rstNewContact = Nothing
  109. End If
  110.  
  111.     Response = acDataErrAdded
  112. End Sub
  113.  
Apr 5 '11 #1
2 1293
weird how the solution appears when you least expect it...
for my part, i had changed the data type of one of the parameters for NotInList on line 86.. NewData as Integer instead of String (as my input table field in that combobox is an integer, and i got a previous data type mismatch for it..)

so changing one datatype messed up the whole code. good to know.
Apr 5 '11 #2
TheSmileyCoder
2,322 Expert Mod 2GB
You cannot (to my knowledge) change the datatypes of standard built-in procedures.

Think of it this way. Access has programmed actions to do, when you type in something that is "NotInList". At some point in the execution of that native access code, it will call or include your custom code. From the nature of the declaration alone, you can see that access has certain expectations from the code.
Expand|Select|Wrap|Line Numbers
  1. Private Sub Combo336_NotInList(NewData As String, Response As Integer)
Even though NotInList is not a function, it does in fact return variables, for instance the Response. Whatever you do with Response will be passed back to the calling procedure, so that access knows how to proceed. If you change the datatype, there will be a datatype mismatch (Access passed you an integer, and was built to expect an integer, but you've changed the program to expect a string or vice versa)

I hope that cleared it up a bit, and didn't just add to the confusion :P
Apr 5 '11 #3

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

Similar topics

4
by: J.C. Flores | last post by:
Hello all, First of all, I must state that I'm new to SQL Server, but have been a long-time software guy for quite some time. Please excuse the potential simplicity of the solution to my...
5
by: murray_shane56 | last post by:
I have a custom application that on occasion requires thousands of TSQL files (on the file system) to be compiled to the database. What is the quickest way to accomplish this? We currently...
2
by: Thierry | last post by:
Hello. Is there any way to redirect the standard out to some variable ? I meen, instead of seending the result to the browser, send it to a variable. Thx, Titi.
10
by: andrewcw | last post by:
I read in a earlier post that I can get the column of a grid to sort by datetime if the column type was set as Date I deserialize my XML and one attribute of the XSD has type as dateTime but upon...
2
by: ad | last post by:
I use ado.net to fill a Excel wroksheet into a DataTable. The data in the Excel wroksheet is digital. After the data filled into the DataTable, the DataType of each column is set to Double, but...
6
by: Sam | last post by:
Hi Here is my code : Code: Dim dt As New DataTable dt.Columns.Add.ColumnName = "New" dt.Columns("New").DataType = System.Type.GetType("System.String") dt.Columns.Add.ColumnName = "Id"...
1
by: Niklas | last post by:
Hi Is it possible to change the standar XML Documentation which is created when you type ///? For example I want a tag named "CreatedBy" and it would be nice if the logged on user name is...
3
by: war | last post by:
hi how to Change datatype from int to decimal with precission 8 and scale 3.in ms sql
2
by: coolminded | last post by:
dear all, i have to modify the datatype of a column of a table. the datatype of the column is varchar(2). i need to increase the length to 20. can u provide the query to change it TIA
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...

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.