473,385 Members | 2,014 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,385 software developers and data experts.

Auto updating form fields

16
Hi

I have two drop down boxes in a form both looking at the same table.
When I select info for the 1st box I want the second box to update with the same information. The code I currently have is:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Ctl1_Person_Responsible_AfterUpdate()
  2. If "Ctl1_Person_Responsible" = 0 Then
  3. Ctl2_Person_Responsible.Enabled = 0
  4. End If
  5. End Sub

This isn't working. Am I right in the 0 being the first row of data, 1 being the second row etc?

Any help as to where I am going wrong would be great!

Thanks
May 13 '10 #1

✓ answered by gershwyn

@jolaunt
If all you want to do is set the second control to the value of the first, try:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Ctl1_Person_Responsible_AfterUpdate()
  2. Ctl2_Person_Responsible = Ctl1_Person_Responsible
  3. End Sub
This will copy whatever value is in the first control to the second whenever the first is changed.

As far as the code you posted, there a couple things wrong with it. First of all, you don't want quotes around your control name. What you are actually doing is comparing the string literal "Ctl1_Person_Responsible" to the number 0, which will never be true, and the rest of your code will never execute. Even if it did, you are then setting the enabled property of your control to zero, which will disable it.

2 1339
gershwyn
122 100+
@jolaunt
If all you want to do is set the second control to the value of the first, try:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Ctl1_Person_Responsible_AfterUpdate()
  2. Ctl2_Person_Responsible = Ctl1_Person_Responsible
  3. End Sub
This will copy whatever value is in the first control to the second whenever the first is changed.

As far as the code you posted, there a couple things wrong with it. First of all, you don't want quotes around your control name. What you are actually doing is comparing the string literal "Ctl1_Person_Responsible" to the number 0, which will never be true, and the rest of your code will never execute. Even if it did, you are then setting the enabled property of your control to zero, which will disable it.
May 13 '10 #2
jolaunt
16
I was over complicating it!

This has worked perfectly.

Thank you
May 13 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: Jason | last post by:
Let's say I have an html form with 20 or 30 fields in it. The form submits the fields via POST to a php page which updates a table in a database with the $_POST vars. Which makes more sense? ...
4
by: bnp | last post by:
Hi All, I am quite new the JavaScript. Basically I am a C++ programmer, but now I am working on JavaScript since last 5 days. I have a problem regarding the form validation. I have created a...
3
by: Andreas | last post by:
Hello list, I suspect, this is a common issue for newbies. Is there a simple way to have an auto-updating timestamp like mysql has ? create table something ( id int4, sometext...
1
by: Spyderman | last post by:
I am fairly new to access but I have found a problem I don't have an answer for. I have a form based on a table. If I change the properties of a field in the table, I was hoping the changes would...
7
by: Chuck Anderson | last post by:
I'm pretty much a JavaScript novice. I'm good at learning by example and changing those examples to suit my needs. That said .... ..... I have some select fields in a form I created for a...
15
by: webstormcomputers | last post by:
I'm trying to update a hidden field with java script and I'm only getting one of the values from my select stament. Here is the code below. <select name="on0"> <option value="25">25 <option...
2
by: mxdllc | last post by:
i would like to create an admin panel for my business. because i have 5 or 6 suppliers and to order i have to lookup which supplier it is then find the url, so to make things a little easier im going...
4
by: parkergirl | last post by:
Hello, I am currently working on a project that has many tabs all on one form. Since you can only have so many controls on one form, my job is to seperate these tabs into forms. One problem that I...
0
by: Mogrin | last post by:
So I have this windows .net form app, and I have the following goals: -Needs to be 1 single file, the executable, in any directory the user decides to download it to. No installation folder, no...
106
by: bonneylake | last post by:
Hey Everyone, Well i don't know if my question should be in javascript/ajax or coldfusion, i figure this is more of a coldfusion question. But if this is in the wrong section let me know an all...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...

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.