473,782 Members | 2,542 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

User new addition to combo box with related fields that need to be populated.

Hi,

I have this code below that will add a new item to a combo box if it
is not in the combo box. I also would like the user to add the
description for the new addition to the combo box and select a
category that it falls into. The description field is a 255 text
field. The category will need to be selected from a dropdown list and
then added to the main reason table.

tblReasonCodes has the following fields, all 255 text.

reason code, description, category

I would like to be able to query the category column to populate the
dropdown box for the user to select a category. Otherwise, I can just
make a category table to use for the dropdown box.

Here is the code I have that will add a new reason code to the drop
down list on the form.

I found the code on Dev Ashish's site.

Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strMsg As String
strMsg = "'" & NewData & "' is not an available reason code. " &
vbCrLf & vbCrLf
strMsg = strMsg & vbCrLf & vbCrLf & "If you would like to add it,
click Yes otherwise Click No."

If msgbox(strMsg, vbQuestion + vbYesNo, "Add new code?") = vbNo
Then
Response = acDataErrContin ue
Else
Set db = CurrentDb
Set rs = db.OpenRecordse t("tblReasonCod es", dbOpenDynaset)
On Error Resume Next
rs.AddNew
rs![Reason Code] = NewData
rs.Update

If Err Then
msgbox "An error occurred. Please try again."
Response = acDataErrContin ue
Else
Response = acDataErrAdded

End If

rs.Close
Set rs = Nothing
Set db = Nothing
End If
End Sub

Thanks
Nov 12 '05 #1
2 1359
Smythe32 wrote:
Hi,

I have this code below that will add a new item to a combo box if it
is not in the combo box. I also would like the user to add the
description for the new addition to the combo box and select a
category that it falls into. The description field is a 255 text
field. The category will need to be selected from a dropdown list and
then added to the main reason table.

tblReasonCodes has the following fields, all 255 text.

reason code, description, category

I would like to be able to query the category column to populate the
dropdown box for the user to select a category. Otherwise, I can just
make a category table to use for the dropdown box.

Here is the code I have that will add a new reason code to the drop
down list on the form.

I found the code on Dev Ashish's site.

Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strMsg As String

strMsg = "'" & NewData & "' is not an available reason code. " &
vbCrLf & vbCrLf
strMsg = strMsg & vbCrLf & vbCrLf & "If you would like to add it,
click Yes otherwise Click No."

If msgbox(strMsg, vbQuestion + vbYesNo, "Add new code?") = vbNo
Then
Response = acDataErrContin ue
Else
Set db = CurrentDb
Set rs = db.OpenRecordse t("tblReasonCod es", dbOpenDynaset)
On Error Resume Next
rs.AddNew
rs![Reason Code] = NewData
rs.Update

If Err Then
msgbox "An error occurred. Please try again."
Response = acDataErrContin ue
Else
Response = acDataErrAdded

End If

rs.Close
Set rs = Nothing
Set db = Nothing
End If
End Sub

Thanks


The question is...what is your question? It appears you are telling us
what you are doing. Did you need help on a combo box? Setting
properties. What the rowsource should be in the combo?

Nov 12 '05 #2
This is my question.....as shown below...

I also would like the user to add the description for the new addition
to the combo box and select a category that it falls into.

So, to reiterate....I can get them to enter the data so it is added to
the table for the combo box but I need them to be prompted to update
the related fields in the underlying table that go with the new combo
box entry.

So, if I add a new code to the box, I have to add a description and a
category.

Thanks,
Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2383
by: Dalan | last post by:
I have been searching the archives in an effort to discover how to derive a dual use of a single combo box - so far no go. I found the piece below which pretty much represents the usage. To summarize: The cboKeyword box on the frmCustomer looks up Keywords from a separate table that have just a list of keywords and a KeyID number. The bound column is tied to the autonumber and is saved in the frmCustomer table. The keywords appear in the...
2
3072
by: visionstate | last post by:
Hi there, I am working on a form that uses 3 text boxes and 3 combo boxes. When any data is entered into any of these, I click a command button and this requeries a sub query in the form and displays data dependent on what has been typed in. After having trouble with populating my second combo box (I eventually populated it by putting the fields for both combo boxes in 1 separate query) I am now having problems with the 3rd one and am...
3
1877
by: fstenoughsnoopy | last post by:
Ok the complete story. I have a Contact Table, Query and Form, that are used to input and store the contact info for customers. They have FirstName, LastName and Address as the primary key fields to keep out duplicates. I am trying to put a full name box on the query, that uses the FirstName, LastName and Middle Initial and puts them together to form a full name. That I have so far. On my order database(consisting of a master table with...
2
1515
by: Ausclad | last post by:
Hi, I have a combo box that I want to populate, based on the selection of another combo box. So when combo box A is selected, combo box B is populated with related values. I have this all working fine, except for on the forms loading. I have combobox B being populated after combobox A_SelectedIndexChanged event fires. However, on the form load, when I try to retrieve the value from
2
5739
by: Mark Roughton | last post by:
I have a form where the users need to view records for various criteria, one of which is a date field on which they may wish to view all related data for the selected date, for all dates upto and icluding the selected date or all records on or after the selected date The user selects either "=", >=" or "<=" from a combo box and then a date from another combobox. The combination of thse two choices is then set in an unbound textbox so...
3
2111
by: sstasiak | last post by:
Hello all I have read similar threads on this site, but can't seem to get any of the solutions working for me. I have a main form(OncRegMain) that adds records to a table(tblOncReg). This table has a primary key(MEDRECNO). What I want to do is create a search form with a combo box containing field columns: MEDRECNO, LNAME, and FNAME from tblOncRegMain. When the appropriate record is selected from the combo box, I want to be able to hit...
1
1873
by: commodityintelligence | last post by:
Greetings, I am merging a series of different tables into one query to export decision-making information. I have some architecture issues I need to ask for help on. I have no programming training. I will explain my structure before asking my questions. I have data from a table (updated monthly by adding the most current month’s data) that is evaluated by certain arithmetic, given an adjective to describe it, and then being exported...
6
8278
by: zuchowra | last post by:
Hi everyone. I need help. I have a combo box in my form that i want to populate multiple text boxes after you select your selection in the combo box. Here is my set up. The Fields that need to be populated are lsited below but must be recorded to a new table. Gets info from Course occurance Table. Combo Box - Gets Information from Course Occurance Table. This table has all information regarding course information. Course ID: Course...
4
13972
by: whamo | last post by:
I have the need to populate a field based on the selection in a combo box. Starting out simple. (2) tables tbl_OSE_Info and tbl_Input; tbl_OSE_Info has three fields: Key, OSE_Name and OSE_Wt tbl_Input has three fields: OSE_Job, OSE_Name, OSE_Wt I have populated tbl_OSE_Info table. I need to create a form that will store the data in tbl_Input I have racked my brain so much trying to figure out how to auto populate a field based on a...
0
9639
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...
0
9479
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10311
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10146
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10080
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
9942
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
8967
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...
0
5378
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4043
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

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.