473,386 Members | 1,745 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,386 software developers and data experts.

Setting one field when another field is entered

How would I set one fields value equal to something based on another table in a form. For instance, could I implement VB on enter in a form's combo box to set a number field equal to one or zero in another table based on the value entered entered in this form( I have a list of 15 names and if a supervisor enters one name as the assignee I want a field DeptID to be either a 1 or 2.

I was thinking it would go something like this
Expand|Select|Wrap|Line Numbers
  1.  Private Sub Assigned_To_Enter()
  2. if Supervisor.Name = "John", employee.deptid = 2
  3. else employee.deptid = 1
  4. end if 
  5. End Sub
I think this is the general idea but I am fairly new to vb and dont' know how to implement this. Any help would be appreciated, I've been working on this app for weeks. Thanks
Sep 7 '06 #1
3 3332
How would I set one fields value equal to something based on another table in a form. For instance, could I implement VB on enter in a form's combo box to set a number field equal to one or zero in another table based on the value entered entered in this form( I have a list of 15 names and if a supervisor enters one name as the assignee I want a field DeptID to be either a 1 or 2.

I was thinking it would go something like this
Expand|Select|Wrap|Line Numbers
  1.  Private Sub Assigned_To_Enter()
  2. if Supervisor.Name = "John", employee.deptid = 2
  3. else employee.deptid = 1
  4. end if 
  5. End Sub
I think this is the general idea but I am fairly new to vb and dont' know how to implement this. Any help would be appreciated, I've been working on this app for weeks. Thanks
Okay I realize now that this would not work, because there would be no way to match up the fields. So instead I was going to assign the value to a text box
like this
Expand|Select|Wrap|Line Numbers
  1. Private Sub Assigned_To_Change()
  2.  Private Sub Assigned_To_Enter()
  3. If "Assigned To" = "John" Then DeptID = 2
  4. Else: DeptID = 1
  5. End If
  6. End Sub
  7.  
I keep getting an error though saying that htere is an else without an if statement
Sep 7 '06 #2
Okay I realize now that this would not work, because there would be no way to match up the fields. So instead I was going to assign the value to a text box
like this
Expand|Select|Wrap|Line Numbers
  1. Private Sub Assigned_To_Change()
  2.  Private Sub Assigned_To_Enter()
  3. If "Assigned To" = "John" Then DeptID = 2
  4. Else: DeptID = 1
  5. End If
  6. End Sub
  7.  
I keep getting an error though saying that htere is an else without an if statement

Okay I fixed that error, but now the value just goes to one even if I select John from the dropdown menu
Sep 7 '06 #3
Got it thanks
Sep 7 '06 #4

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

Similar topics

2
by: John Hargrove | last post by:
I'm having trouble setting decimal place values in the results field of a sample management database I'm building for an environmental testing laboratory. The degree of sensitivity varies among...
5
by: Bob | last post by:
I have a form with controls City and Zip Code, and a Table containing Zip Code with the corresponding City. I would like the user to just enter Zip Code, either by typing or with a combo box; then...
1
by: Corrine | last post by:
AssignedEquipmentType and AssignedEquipment are text data type. Both are unique five character codes. I have both fields in a continuous form. The database requires that if an Equipment type is...
2
by: Megan | last post by:
Hi everybody- I have 2 tables, Hearings and Rulings. Both have primary keys called, CaseID, that are autonumbers. I don't want both tables to have the same autonumber. For example, if Hearings...
11
by: Zlatko Matić | last post by:
Hello. I have a MS Access front-end working with PostgreSQL database. I have successfully created saved File DSN. My paa-through queries are referring to that file as well as linked tables. But I...
18
by: Dixie | last post by:
Can I set the Format property in a date/time field in code? Can I set the Input Mask in a date/time field in code? Can I set the Format of a Yes/No field to Checkbox in code? I am working on...
2
by: Bex | last post by:
Hi All. I'm attempting at the moment to set the recordsource of an unbound subform when i open up it's main form. My view is to have one intial form - called "Search" which has a number of...
9
by: sellcraig | last post by:
Microsoft access 2 tables table "data main" contains a field called "code" table "ddw1" is created from a make table query of "data main" Goal- the data in "code" field in needs to...
9
by: Ecohouse | last post by:
I have a main form with two subforms. The first subform has the child link to the main form identity key. subform1 - Master Field: SK Child Field: TrainingMasterSK The second subform has a...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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.