OKay so i have a combobox with 2 fields, City and CityCode. (i.e. Albany, ALBA) I want to be able to type in a new citycode or city so that when it's not in the list the user can add it to the list along with the field that they're not entering which would be city or citycode. Please help! thanks
User pick a record from a list and are able to doubleclick that record which will open another form with that record's ID. If the field is Null, then another form opens allowing the user to create a new record. The part that doesn't work, is if that record that was in the combo, gets deleted from somewhere else. Then the ID is still being shown in the combo (that's OK but it's no longer null), so double clicking the field does not bring up the correct Create New record form.
What I would like to have is something similar to the NotInList message that states something like, "That record has been deleted". This is what I have so far,If not in list
Code:
Private Sub APID_NotInList(NewData As String, Response As Integer) MsgBox "Please select an ... or double-click this field to add a new entry to the list." Response = acDataErrContinue APID = Null End Sub
On double clicking the combo
Code: Private Sub APID_DblClick(Cancel As Integer) Dim stDocName As String Dim stLinkCriteria As String
I have a form frm_GlobalSettings with a combobox cmbDescription that finds a record based on the value selected. The row source type for cmbDescription is Table/query, and the row source is a select statement on the form's underlying table.
I want the user to be able to use cmbDescription to add a new record to the form's underlying table. I currently have
Code:
Private Sub cmbDescription_NotInList(NewData As String, Response As Integer) Dim strTmp As String 'Get confirmation that this is not just a spelling error. 10 On Error GoTo cmbDescription_NotInList_Error 20 strTmp = "Add '" & NewData & "' as a new global setting?"
[code]....
but when a new value is entered this errors on line 70 with "runtime errror 2118 - you must save the current field before you run the requery action".I've tried various ways around this but can't get it to work.
I have a data entry form where country(ies) (there can be more than one for each project) is/are entered in a sub-form on a tab control. Countries not listed are entered by the following:
Private Sub CountryName_NotInList(NewData As String, Response As Integer) Dim strSQL As String Dim strMsg As String Dim ctl As Control Set ctl = Screen.ActiveControl
strMsg = "Country " & NewData & " Is not listed!" & vbCrLf & "Do you want to add it?" If MsgBox(strMsg, vbYesNo, "Not listed") = vbYes Then strSQL = "INSERT INTO tblCOUNTRY (CountryName) " strSQL = strSQL & "VALUES('" & NewData & "');" CurrentDb.Execute strSQL Response = acDataErrAdded Else ctl.Undo Response = acDataErrContinue End If End Sub
This works fine. However, if I restrict the country names by a region selection on the main form (for example if region Africa is selected on the the African countries are preselected) the NotIn List does not work. Any way to work around this?
Another question, I want the user to select a region (a combo box ) on the main form and when a new country (using the NotInList event) is entered in the subform both values go into the same record in tblCountry (which has two fields CountryName and Region). For example, I enter AFRICA for region on the main form and on the sub-form I enter Malawi which is not listed. I have tried the following:
Private Sub CountryName_NotInList(NewData As String, Response As Integer) Dim strSQL As String Dim strMsg As String Dim ctl As Control Set ctl = Screen.ActiveControl
strMsg = "Country " & NewData & " Is not listed!" & vbCrLf & "Do you want to add it?" If MsgBox(strMsg, vbYesNo, "Not listed") = vbYes Then strSQL = "INSERT INTO tblCOUNTRY (CountryName, Region) " strSQL = strSQL & "VALUES('" & NewData & "', FORMS!frmAddPro!Region);" CurrentDb.Execute strSQL Response = acDataErrAdded Else ctl.Undo Response = acDataErrContinue End If End Sub
But it does not work (Region is the control on the main form named frmAddPro). Any suggestions would be welcome. Thanks. Niels
I added the notinlist event to an unbound combo (I use access 2003) and used the ADO code but no matter what I try I can't get it working. Out of desperation I substituted the DAO code and "bingo" I have a working combo which adds any data I type in etc, no errors no problems. My question now is; Do I now stick with the old rule "if it ain't broke don't fix it" and continue using the DAO code or do I continue to pull my hair out (not much left now) trying to get the ADO code working?
This is the NotInList I have been using for some time (below). it works well but only updates one field. I need to update two fields now, City and ZipCode. Can I add data to two fields each time the notinlist is envoked?
On Error GoTo Err_ErrorHandler Const Message1 = " Is Not In The Database." Const Message2 = "Would you like to add it?" Const Title = "Unknown entry..." Const NL = vbCrLf & vbCrLf Dim db As DAO.Database Dim rs As DAO.Recordset If MsgBox(NewData & Message1 & NL & Message2, vbQuestion + vbYesNo, Title) = vbYes Then Set db = CurrentDb Set rs = db.OpenRecordset("MyTbl or Qry") With rs .AddNew .Fields("MyField") = NewData .Update .Close End With Response = acDataErrAdded Else Me.MyField.Undo Response = acDataErrContinue End If Exit_ErrorHandler: Set rs = Nothing Set db = Nothing Exit Sub Err_ErrorHandler: MsgBox Err.Description, vbExclamation, "Error #" & Err.Number Resume Exit_ErrorHandler
hey Well I'm haveing some problems here. When I type something in my combobox that aint in the list it doesnt go to the precedure NotInList.
I need this for both of these comboboxes and I tried an altarnative way with rowsource but that aint working aswell so here is the code
Private Sub cboReeks_AfterUpdate() If cboReeks.Text <> cboReeks.RowSource Then Call Foutmelding("U hebt een foutieve waarde ingevoerd") cboReeks.Value = "" End If End Sub
Private Sub cboRonde_NotInList(NewData As String, Response As Integer) Response = 0 Call Foutmelding("U hebt een foutieve waarde ingevoerd") cboRonde.Value = "" End Sub
Hi all. This is the code that I have used in my NotInList event
Private Sub Suppliers_NotInList(NewData As String, Response As Integer) On Error GoTo Err_Suppliers_NotInList
'-- We may need to add another Product Response = MsgBox("[" & NewData & "] is not yet a valid Supplier..." & vbCr & vbCr & _ "Would you like to add this Supplier to your DataBase?", vbYesNo)
If Response = vbYes Then '-- Create a new Product record Dim db As DAO.Database Dim MySQL As String Set db = CurrentDb() MySQL = "Insert Into TableSupplier (Suppliers) " & _ "Values(""" & NewData & """)" db.Execute MySQL, dbFailOnError Set db = Nothing Response = acDataErrAdded '-- will requery!! Else Response = acDataErrContinue End If
Exit_Suppliers_NotInList: On Error Resume Next Set db = Nothing Exit Sub
Err_Suppliers_NotInList: MsgBox "Error No: " & Err.Number & vbCr & _ "Description: " & Err.Description Resume Exit_Suppliers_NotInList End Sub
The problem i'm having is that the code is not working. However, I have used the same code but modified to suit on another field elsewhere in the form which works fine. Any ideas????
Hi All, I'am using the following code to update a table (tbl_CDT) on a NotInList event of a cboBox (CDT) I keep getting a SQL syntax error message, can anyone help resolve the code please
Private Sub CDT_NotInList(NewData As String, Response As Integer)
On Error GoTo CDT_NotInList_Err Dim intAnswer As Integer Dim strSQL As String intAnswer = MsgBox("The CDT " & Chr(34) & NewData & _ Chr(34) & " is not currently listed." & vbCrLf & _ "Would you like to add to the list now?" _ , vbQuestion + vbYesNo, "DentureBase") If intAnswer = vbYes Then strSQL = "INSERT INTO tbl_CDT's([CDT_Name]) " & _ "VALUES ('" & NewData & "');" DoCmd.SetWarnings False DoCmd.RunSQL strSQL DoCmd.SetWarnings True MsgBox "The new CDT has been added to the list." _ , vbInformation, "DentureBase" Response = acDataErrAdded Else MsgBox "Please choose a CDT from the list." _ , vbInformation, "DentureBase" Response = acDataErrContinue End If CDT_NotInList_Exit: Exit Sub CDT_NotInList_Err: MsgBox Err.Description, vbCritical, "Error" Resume CDT_NotInList_Exit
I have a combo box which is used to find a record on the form. I have set LimitToList = Yes and put in code for the event NotInList.
My problem is that my code is working fine allowing me to produce my own message, but then the standard message appears as well saying "The text you entered is not an item in the list"
Looking for a way to supress this message box... The text you entered isn't an item in the list.
Select an item from the list or enter text that matches one of the listed items. ... when the NotInList event fires.
Trying to just open an unbound modal form, pass a couple values to it, and set focus on a particular combobox for additional information to be added to my lookup table:
Private Sub cboPostalCode_NotInList(NewData As String, Response As Integer)
On Error GoTo Err_ErrorHandler
Const Message1 = "The postal code you have entered is not currently on record." Const Message2 = "Would you like to add it?" Const Title = "Unknown Postal Code" Const NL = vbCrLf & vbCrLf
If MsgBox(Message1 & NL & Message2, vbQuestion + vbYesNo, Title) = vbYes Then DoCmd.OpenForm "frmPostalCode" Forms!frmPostalCode!cboCountryID = Me.cboCountryID Forms!frmPostalCode!txtPostalCode = NewData Forms!frmPostalCode.SetFocus Forms!frmPostalCode!txtCity.SetFocus Else Me.cboPostalCode.Undo End If
I have 2 Cascading Combo boxes setup and working correctly.cbo1 lists all agents and cbo2 lists the branches that relate to each agent.tbl_agents and tbl_branches are setup with a 1 to many relationship.I have used the code (explained here (http://www.fontstuff.com/access/acctut20.htm)) that allows the user to add a new agent if they are not in the list. This works correctly. Now I want to let the user add a new branch for the agent they have just added. The code appears to work correctly from the front end, but when you check tbl_branch, there is a new entry but it is missing the appropriate agentID foreign key (ie, it's not related to the new agent).Is there something that I'm missing? I assume this is possible, but I must be doing something wrong.Maybe I need to create a little pop-up form for data entry?any help appreciated.
I am working on a database project using Access 2010 and encounter some ComboBox text color problem,
The form has a ComboBox that displays the Supplier Name. The Combo's source control is Supplier ID in the Products table which joints the Supplier Table containing the Supplier Name. To display the Supplier Name only, I use a column count of 2 (for VendorID and VendorName) and column width of 0";2" so as to hide the SupplierID.
VBA is used to dynamically change the ForeColor and BackColor (via the Control Property ".ForeColor" etc) of the text in the ComboBox and TextBox. This works well for all TextBoxes and the ComboBoxes with direct data from the Products Table. However, for the ComboBox of VendorName, the BackColor can change but the ForeColor always remains as black. I have tried using the Format query such as "[White];@;[White];@" which works on the TextBox and other ComboBox (with direct field data from table), but the situation remains the same on this ComboBox which uses join-table reference via the VendorID.
In my Patients table i have a field called PatientID (AUTONUMBER) as my primary key I hve another problem. Is this possible as i hve been trying for two days now. I hve tried a lot of ways but i cant get it to work right. I have a table called dependents. ID , PatientID,,Dependents,DOB,Age id being the PK AND PatientID as a number I have a table called vitals. with ID,PatientID,PatientName( which is a dropdown of Dependents), hpp,sats etc. (This is a subform in datasheet style in another form)
In my table vitals i have the follwing for PatientName . comboxbox.
SELECT Dependents.Dependents, DateDiff("yyyy",[DOB],Now())+Int(Format(Now(),"mmdd")<Format([DOB],"mmdd")) AS Age FROM Dependents;
So it selects fine in a dropdown like John 48, smith 36.
The problem i have is that it selcts all the records irrespective of PatientID.
I am new to access. I have the following code to lookup associated fields with a CourseNumber that is selected from a combobox. The information is then stored in a CourseEnrollment table linked to student info.
The CourseNumber and associated fields are located in a LU_CoursesOffered table. The LU_Courses Offered table has been populated by choosing associated data from combo boxes based on other LU tables.
I am getting the primary keys returned for the associated data rather than the text stored with that key.
Table Name: Student Fields: Auto (Primary Key) MOI (number) Name (Text)
I have 2 forms: 1) Student ,which contains student info I have created a combo box in this form for MOI, so whenever I type an MOI ID that have been previously entered I get the student Name, if it's not previously entered I used the NotInList Event, that asks the user if he wants to add the new value in the list if Yes, it will forward him to the second form
2) student_info, which is an entry form the user enters the name of the student and go back to the student form.
The following is the NotInList event code:
Private Sub Combo10_NotInList(NewData As String, Response As Integer) Dim Result Dim Msg As String Dim CR As String
CR = Chr$(13)
' Exit this subroutine if the combo box was cleared. If NewData = "" Then Exit Sub
' Ask the user if he or she wishes to add the new student. Msg = "'" & NewData & "' is not in the list." & CR & CR Msg = Msg & "Do you want to add it?" If MsgBox(Msg, vbQuestion + vbYesNo) = vbYes Then
' If the user chose Yes, start the student_info form in data entry ' mode as a dialog form, passing the new MOI in ' NewData to the OpenForm method's OpenArgs argument. The ' OpenArgs argument is used in student_info form's Form_Load event ' procedure. DoCmd.OpenForm "student_info", , , , acAdd, acDialog, NewData End If
' Look for the student the user created in the student_info form. Result = DLookup("[MOI]", "student", _ "[MOI]='" & NewData & "'") If IsNull(Result) Then
' If the student was not created, set the Response argument ' to suppress an error message and undo changes. Response = acDataErrContinue
' Display a customized message. MsgBox "Please try again!" Else
' If the customer was created, set the Response argument to ' indicate that new data is being added. Response = acDataErrAdded End If
End Sub
The code is working perfectly except for one problem:
When I'm in student_info form to enter the name of new student and I want to go back to the Student Form I have this error message:
data type mismatch in criteria expression
I figured maybe because I'm passing a number field and in the DLookup criteria it assigns the MOI (which is number) to NewData which is String as follow:
I have two tables: Products and Invoice. Product table is for creating product list which will have additional information about products for calculations latter. Invoice is table which contains information about invoices and bought products. Invoice table column Product is combo box which I created that user wouldn't type same product in 100 variations (list is from table product column product description).
One invoice can contain more than one product which is not in product. NotinList add notinlist products to list but only one product at time (at least I know only this way).
Is it possible to add multiple records with notinlist? what i would like to to is:
1. user adds new invoice and access doesn't bothers with error messages about item not in list 2. after invoice have been added, access checks if all product is in list and offers to add those ones which is not in list to add to list.
I am trying to get two different fields to autopopulate when I select a choice from a combo-box on my form.
I have a form called IncomeRcvdFrom, which takes its fields from the table "IncomeRcvd"
In the form, I have three fields that need to relate to each other and auto populate.
The first field is called "IncmType", which comes from a different table called "CategoriesList". There is another field called "IncmDescr" which also comes from the same table. The third field, called "Category" is a list box in that table that comes from another table called "CatType".
All three of these fields also are list boxes in the table "IncomeRcvd", where the source of these fields come from the "CategoriesList" and the "CatType" tables.
What I am trying to accomplish is so when someone selects an Account, or "IncmType", it auto populates the "IncmDescr" field, as well as the "CatType" field on the form.
So far, I have gotten the Account or IncmType and the IncmDescr fields to autopopulate each other, but the Category field either says "Name?", or I get the "type mismatch expression" error message. I also accidentally got the field to work one time, but it would only display the ID Key field and not the actual wording in the rows (i.e. Misc. Payment, Royalty, Rebilling, etc.)
I have checked my relationships, my control sources, and still can't get it to work.
Code: SELECT S.Key, S.Spec FROM tblSpecs AS S ORDER BY S.Spec;
NotInList code:
Code: Private Sub cboSpecs_NotInList(NewData As String, _ Response As Integer) ' MODIFY SPEC ENTRY. 10 Dim db As Database
[Code]....
1) For some reason, txtMessage is not displayed on the form when NotInList is processed. I see it get populated properly in debug mode, but it never gets on the form. But txtMessage gets displayed normally in Add and Delete events.
It seems to do with the way NotInList works because txtMessage is displayed if I use acDataErrContinue. But that's not what I want; it leaves the combobox list open and can't save record if I close the form.
2) DLookup is used to extract the old Spec value to display in the message. I can see the old Spec in debug mode in cboSpec.column, but Listindex is -1 and unusable.
I don't know how to point to the proper record in the list. The only other way I can think of is to loop through the list comparing the Key, and then extract the Spec.
I don't know if it's more efficient to use lookup or loop.
I have a form with a subform that contains a combobox where I choose companies to add to a project that is on the main form. If the user types in a company name that is not in the database, I run code on the NotInList event that passes the company name using openargs to a company entry form.
After this form is closed, I return to the subform to choose the company name that I just added, only it is not there because I can't figure out where to automatically requery this combobox. My duct tape solution that's working, is a command button that runs this code when clicked:
I have tried putting this code in the OnCurrent, OnFocus, Onclick, OnEnter....etc on the subform and on the combobox itself. So far the only way it requeries is if I use the command button.if you want to see the NotInList code, and the code on my company entry form.
I have a form in which I have a combobox. The code in the row source is:
Code: SELECT [tblBooks].AuthorFirst & " " & [tblBooks].AuthorLast AS Expr1 FROM tblBooks GROUP BY tblBooks.AuthorLast, tblBooks.AuthorFirst HAVING (((tblBooks.AuthorFirst & " " & tblBooks.AuthorLast)<>"") And ((Count(*))>1)) ORDER BY tblBooks.AuthorLast, tblBooks.AuthorFirst;
This is an unbound box.
The rest of the form contains bound textboxes and other bound comboboxes.
This form is processed by the following VBA code:
Code: Private Sub cmdAddBook_Click() 'Place the authors first and last name in an array splitAuthor = Split(cboAuthor.Value, " ") 'Create a new record with the form information DoCmd.GoToRecord , , acNewRec
[Code] ....
What happens is that it places all the records (Except those in the array) in a field and overwrites the values in that field.
I have used the same GoToRecord statement on other databases and it works just fine. I suspect that it is due to the unbound combobox.
What I need to find a way to place all the data in the corresponding fields of a new record including separating the author's first and last name when retrieved from the combobox. I just need to figure out how to get the data in the table somehow.
I have a data base with names, email IDs, phone numbers of 5 types(example quality, security, IT,finance etc) of person from ten different project teams. I created a basic form for the end user to enter values and created fields for each of the person's name, email ID etc based on the personal type( liek quality, IT, finance etc) on each team. The background table contains records of almost 200 people now.
All of these people will be trained for one task and some will be trained for multiple tasks. I know how to make the combo box allow multiple values/selections but, i cannot list out all 200 personal names in the combobox's rowsource/value list. Is it possible to combine all different name fields and list out all personal(of one team), so that the end user can just select multiple names for that team who have been trained and so on. i need to set the rowsource of the combobox to the values of all personal from one team so the team leader can just go select who has been trained and who has not.
I have a table (ComponentT) of different device components a user can select from ( generators, gearboxes, etc.)
The table has 3 fields - ComponentName, ComponentType, ComponenentDetails
I have a query returning all the ComponentDetails values.
I then have a combobox that uses this query as a row source.
The user can select different components they want from the combobox. Once something is selected, it is added to a new table - UserSelectedComponentsT
As a device can have only one gearbox or one generator etc. I want a warning messagebox to be displayed if the user tries to select a generator from the combobox when one has been previously selected.
I have a Table with 57 fields. I would like to display this table in a form as a subform, but only certain fields depending on what selection is made in a combo box.
For instance, if the user selects "Missing Information" in the Combo Box, then the form will show a few standard fields such as ID, Market, Sales Manager, and then some specific ones such as date missing information requested and date missing information received.
If the user selects another option, again the standard fields will remain plus a few different ones.
I have done much searching on this and feel like I am so close but so far. I have looked into controlling the record source of the subform, columhidden =false and a multitude of others. All of which may or in fact probably do work in this situation but I can't seem to put it all together.
I have a login form with a combobox which derives its list of values from an EmployeeRecord table (i.e., last name, first name, securityID, job grade and record number): only the last name and first name appear in the list. (I swiped some VB code for a multiuser login form and routine from several previous posts.)
After it performs the security validation/authorization, it then opens a navigation control form based upon the user's job grade. It runs after the click button event. To this I would like to update another table, LoginEvent, with the last name, first name and record number from the combobox selection, and also add the time and date of the click.
:confused: I need to find a way using macros to accomplish this task: I am trying to set the LimitToList property as a YES, and enter data that is not in the list already, but instead of the NotInList property giving me the following error "The item you entered is not in the list. Please choose one from the contents of the drop down box", I want to branch to a macro entered at theNotInList property to branch to that will eliminate the error, and give me the opportunity to enter my own message with options for the user to enter the item into the list, or try to choose an item from the drop down box instead. I want to do this with a macro if possible. I have seen many VB solutions that purport to solve the issue, but to be honest, I am not very well versed in VB procedures. That's why I would like to do it with a macro. I am very competent with macro procedures! Please help ASAP. Thanks.