473,387 Members | 1,844 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.

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 = acDataErrContinue
Else
Set db = CurrentDb
Set rs = db.OpenRecordset("tblReasonCodes", dbOpenDynaset)
On Error Resume Next
rs.AddNew
rs![Reason Code] = NewData
rs.Update

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

End If

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

Thanks
Nov 12 '05 #1
2 1344
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 = acDataErrContinue
Else
Set db = CurrentDb
Set rs = db.OpenRecordset("tblReasonCodes", dbOpenDynaset)
On Error Resume Next
rs.AddNew
rs![Reason Code] = NewData
rs.Update

If Err Then
msgbox "An error occurred. Please try again."
Response = acDataErrContinue
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
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...
2
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...
3
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...
2
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...
2
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...
3
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...
1
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...
6
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...
4
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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.