473,657 Members | 2,625 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Fill field with chosen value from a drop down combo box

I need to fill a table with values. The table has about 6000 records
but the records will not have the same value in this field. I thought
I had figured out a way to do this easily but it is giving me an
error.

Object or provider is not capable of performing requested operation.

Basicly I am choosing a department in a combo box(Combo1) and a charge
number(Combo3) in the form. They are both unbound.

I want to add the charge number to the CALFILES table which is chosen
in the charge number box for all records with the department chosen in
Combo1

Here is the code.

Private Sub Command0_Click( )
On Error GoTo Err_Command0_Cl ick

Dim con As Object
Dim rs As Object
Dim stSql As String
Dim intOption As Integer

Set con = Application.Cur rentProject.Con nection

stSql = "SELECT * FROM [CALFILES] WHERE [Department]=" &
Me![Combo1]

Set rs = CreateObject("A DODB.Recordset" )
rs.Open stSql, con, 1 ' 1 = adOpenKeyset
While (Not (rs.EOF))
rs![ChargeNumber] = Me![Combo3]
rs.MoveNext
Wend

rs.Close
Set rs = Nothing
Set con = Nothing
Exit_Command0_C lick:
Exit Sub

Err_Command0_Cl ick:
MsgBox Err.Description
Resume Exit_Command0_C lick

End Sub
Nov 13 '05 #1
2 2341
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

It would be easier to run a query instead of looping thru a recordset to
update a table. E.g.:

Put this in a query object's SQL view:

PARAMETERS Forms!form_name !Combo1 Long,
Forms!form_name !Combo3 Long;
UPDATE CalFiles
SET ChargeNumber = Forms!form_name !Combo3
WHERE Department = Forms!form_name !Combo1

Substitute the ComboBoxes' form's name for "form_name" in the above
parameters. I set the parameters' data types to Long, change to the
appropriate data type.

Run the query from the OnClick event of the CommandButton.

For later maintenance, it helps if the control names are more
descriptive than Combo1, Combo3. How about cboDepartment and
cboChargeNumber , respectively?

--
MGFoster:::mgf0 0 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQRfg2YechKq OuFEgEQKSNQCfYF 5B/I4q7qjF+L2N/wa7ULgNXjsAoJOV
6/wo8+L0bnDw8oZmt CtPlACK
=s49R
-----END PGP SIGNATURE-----
Dannic wrote:
I need to fill a table with values. The table has about 6000 records
but the records will not have the same value in this field. I thought
I had figured out a way to do this easily but it is giving me an
error.

Object or provider is not capable of performing requested operation.

Basicly I am choosing a department in a combo box(Combo1) and a charge
number(Combo3) in the form. They are both unbound.

I want to add the charge number to the CALFILES table which is chosen
in the charge number box for all records with the department chosen in
Combo1

Here is the code.

Private Sub Command0_Click( )
On Error GoTo Err_Command0_Cl ick

Dim con As Object
Dim rs As Object
Dim stSql As String
Dim intOption As Integer

Set con = Application.Cur rentProject.Con nection

stSql = "SELECT * FROM [CALFILES] WHERE [Department]=" &
Me![Combo1]

Set rs = CreateObject("A DODB.Recordset" )
rs.Open stSql, con, 1 ' 1 = adOpenKeyset
While (Not (rs.EOF))
rs![ChargeNumber] = Me![Combo3]
rs.MoveNext
Wend

rs.Close
Set rs = Nothing
Set con = Nothing
Exit_Command0_C lick:
Exit Sub

Err_Command0_Cl ick:
MsgBox Err.Description
Resume Exit_Command0_C lick

End Sub


Nov 13 '05 #2
MGFoster <me@privacy.com > wrote in message news:<Gh******* ************@ne wsread1.news.pa s.earthlink.net >...
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

It would be easier to run a query instead of looping thru a recordset to
update a table. E.g.:

Put this in a query object's SQL view:

PARAMETERS Forms!form_name !Combo1 Long,
Forms!form_name !Combo3 Long;
UPDATE CalFiles
SET ChargeNumber = Forms!form_name !Combo3
WHERE Department = Forms!form_name !Combo1

forgot about a sql type query. That should work just fine.
For later maintenance, it helps if the control names are more
descriptive than Combo1, Combo3. How about cboDepartment and
cboChargeNumber , respectively?


I would if it were reoccuring. This is a one time deal to get the
database filled with almost the proper data for a new field. So once
I have this done I'll never need the darn thing again.

Thanks. Let ya know the outcome.

Billie Kennedy
Nov 13 '05 #3

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

Similar topics

5
2415
by: Elvis V. | last post by:
Good morning, I have a table with three fields, Buildings, Floors and Rooms. This is what I would like to do; in my form when I select Building1 in my drop down box for Buildings, when I go to the next drop down field which is Floors, all I would like to see is just the floors that belong to Building1 only and then once I have selected a value for Floors, when I go to the next drop down field which is Rooms, all I want to see are the...
3
12589
by: sao | last post by:
I am currently using Access 2000. In my table it is the following fields that are set up: 1 - Staff Name 2 - Department This table is already populated with 100+ records (staff along with department.)
2
6593
by: G.Gerard | last post by:
Hello Does anyone know how to get an entire memo field to be displayed in a combo box drop down list? Example - if the memo field contains the following : This is a test to see if
4
4708
by: Sherwood Botsford | last post by:
Table Markers ID (Primary Key) This&That PointClass (Combo box) Points Table PointClasses PointClass (primary key) Points (number) Description (Text)
8
18341
by: Lyn | last post by:
Hi, Can anyone tell me how the initial value displayed in Combo Box is determined when a form is opened? I am loading the dropdown from one field ("CategoryName") of a table, with "ORDER BY ". The values in the dropdown are loaded in the correct order, but the initial value is not the first row of the dropdown as I expected. The field "CategoryName" is not the primary key for the table -- the PK is
2
6947
by: Jeremy Dillinger | last post by:
I have a program setup to pull data from a database. My database table has things such as (category, Item, price, etc.) In my program I want to have multiple list boxes that will have a pull down list of different categories. The category is stored as a number and the item is stored as a string. Also once the item is picked from the list I would also like to extract the price corresponding to the chosen item. This program will be to...
8
6387
by: sara | last post by:
I have a table where a few of the users entered vendor names ALL IN UPPER CASE. I have created forms to edit the data, but I can't seem to allow changing JOE SMITH to Joe Smith. What to I have to do to have the user change the name, but keep the key? Overall, I think any "edits" simply add a new record, rather than change the existing record. The form is simple - Choose the vendor from the drop-down list. After Update, a new field...
3
7345
by: penny111 | last post by:
Hi there, For my application, i need to have 3 drop down lists 1. drop down list of folder names 2. drop down list of documents in the folder selected 3. drop down list of instances of the document selected (my application uses the BusinessObjects Java Web Services SDK) The 2nd list is dependent on the 1st, while the 3rd list is dependent on the 2nd. In other words, this is what i want my application to do -select a folder from the...
1
2345
by: bytenut | last post by:
I would like to display two field values in a combo after selecting from the list items... i.e. my drop-down shows two fields from a lookup, but when I select the item, only the first field value is shown in the combo text area (at the top)... (bound field is invisible) e.g. Currently seeing (standard behavior) drop-down | 1 drop-down | 2 drop-down | 3
0
8823
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
8730
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
8503
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
8605
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
7321
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...
1
6163
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4151
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...
0
4301
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1950
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.