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.. -
Option Compare Database
-
-
Private Sub Combo333_BeforeUpdate(Cancel As Integer)
-
-
End Sub
-
-
Private Sub Combo336_KeyDown(KeyCode As Integer, Shift As Integer)
-
'Form_Query18.Combo336.Dropdown
-
End Sub
-
-
Private Sub Combo336_NotInList(NewData As String, Response As Integer)
-
-
Dim strMsg As String
-
Dim MyDB As DAO.Database
-
Dim rstNewContact As DAO.Recordset
-
-
strMsg = "'" & NewData & "' is not in the list. "
-
strMsg = strMsg & "Would you like to add a New Customer?"
-
-
If vbNo = MsgBox(strMsg, vbYesNo + vbQuestion, "New Customer") Then
-
Response = acDataErrDisplay 'Access displays its standard Error Message
-
Else
-
'Decided to Add the New Customer
-
Set MyDB = CurrentDb
-
Set rstNewContact = MyDB.OpenRecordset("Contacts", dbOpenDynaset)
-
rstNewContact.AddNew
-
rstNewContact("LastName") = NewData
-
rstNewContact.Update
-
-
Response = acDataErrAdded 'Item added to underlying Recordset and the Combo
-
'Box is Requeried, Item added to List
-
rstNewContact.Close
-
Set rstNewContact = Nothing
-
End If
-
bolNewRec = True
-
-
End Sub
-
-
Private Sub Combo340_KeyDown(KeyCode As Integer, Shift As Integer)
-
If bolNewRec = True Then
-
Form_Query18.Combo340.AutoExpand = False
-
-
Else
-
Form_Query18.Combo340.Dropdown
-
End If
-
End Sub
-
-
Private Sub Combo340_NotInList(NewData As String, Response As Integer)
-
-
Dim strMsg As String
-
Dim MyDB As DAO.Database
-
Dim rstNewContact As DAO.Recordset
-
-
strMsg = "'" & NewData & "' is not in the list. "
-
strMsg = strMsg & "Would you like to add a New Customer?"
-
-
If vbNo = MsgBox(strMsg, vbYesNo + vbQuestion, "New Customer") Then
-
Response = acDataErrDisplay 'Access displays its standard Error Message
-
Else
-
'Decided to Add the New Customer
-
Set MyDB = CurrentDb
-
Set rstNewContact = MyDB.OpenRecordset("Contacts", dbOpenDynaset)
-
rstNewContact.MoveLast
-
rstNewContact.Edit
-
rstNewContact("FirstName") = NewData
-
rstNewContact.Update
-
-
Response = acDataErrAdded 'Item added to underlying Recordset and the Combo
-
'Box is Requeried, Item added to List
-
rstNewContact.Close
-
Set rstNewContact = Nothing
-
End If
-
-
Response = acDataErrAdded
-
End Sub
-
-
Private Sub Mobile_KeyDown(KeyCode As Integer, Shift As Integer)
-
If bolNewRec = True Then
-
Form_Query18.Mobile.AutoExpand = False
-
-
Else
-
Form_Query18.Mobile.Dropdown
-
End If
-
End Sub
-
-
Private Sub Mobile_NotInList(NewData As Integer, Response As Integer)
-
Dim strMsg As String
-
Dim MyDB As DAO.Database
-
Dim rstNewContact As DAO.Recordset
-
-
strMsg = "'" & NewData & "' is not in the list. "
-
strMsg = strMsg & "Would you like to add a New Customer?"
-
-
If vbNo = MsgBox(strMsg, vbYesNo + vbQuestion, "New Customer") Then
-
Response = acDataErrDisplay 'Access displays its standard Error Message
-
Else
-
'Decided to Add the New Customer
-
Set MyDB = CurrentDb
-
Set rstNewContact = MyDB.OpenRecordset("Contacts", dbOpenDynaset)
-
rstNewContact.MoveLast
-
rstNewContact.Edit
-
rstNewContact("Mobile") = NewData
-
rstNewContact.Update
-
-
Response = acDataErrAdded 'Item added to underlying Recordset and the Combo
-
'Box is Requeried, Item added to List
-
rstNewContact.Close
-
Set rstNewContact = Nothing
-
End If
-
-
Response = acDataErrAdded
-
End Sub
-
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.
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. - 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
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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.
|
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...
|
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...
|
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"...
|
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...
|
by: war |
last post by:
hi
how to Change datatype from int to decimal with precission 8 and scale 3.in ms sql
|
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
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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,...
|
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,...
|
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...
| |