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

update lookup field

I realize that lookup fields in a table should not be used but that is
the way this particular creator has done. Could someone help me by
answering my question.

I am trying to run a DoCmd.RunSQL command in code and my question is
how do I write a sql statement in code that updates the fldTeacher1
field with a new value?

The main table is tblStudent and the lookup table is tblTeacher. The
lookup field in tblStudent is fldTeacher1 and looking at the properties
of fldTeacher1 I see that it has values under the lookup tab of:

Bound Column: 1
Column Count: 2
Column Widths: 0";1" (id number; teacher's Name)

I have tried:
DoCmd.RunSQL ("UPDATE tblStudent SET fldTeacher1 = " & Val(txtID) & "
WHERE fldID = " & gintStudentID & ";")

All it does is place the id # in the field and not display the
teacher's name in fldTeacher1 after the command was run.

Can someone please tell me how I am to update tblStudent.fldTeacher1
with a value from tblTeacher through a sql statement in vba? I really
could use help other than the table should not use lookup fields.

Apr 21 '06 #1
1 3986
> I have tried:
DoCmd.RunSQL ("UPDATE tblStudent SET fldTeacher1 = " & Val(txtID) & "
WHERE fldID = " & gintStudentID & ";")
well, that can't be the entire SQL statement - where's the FROM clause? how
about posting *all* the SQL, and explain where you're seeing "the id # in
the field and not display the teacher's name in fldTeacher1 after the
command was run". are you in a form? a query? in tblStudent's table
datasheet view?

hth
"sierra467" <si*******@gmail.com> wrote in message
news:11**********************@i39g2000cwa.googlegr oups.com... I realize that lookup fields in a table should not be used but that is
the way this particular creator has done. Could someone help me by
answering my question.

I am trying to run a DoCmd.RunSQL command in code and my question is
how do I write a sql statement in code that updates the fldTeacher1
field with a new value?

The main table is tblStudent and the lookup table is tblTeacher. The
lookup field in tblStudent is fldTeacher1 and looking at the properties
of fldTeacher1 I see that it has values under the lookup tab of:

Bound Column: 1
Column Count: 2
Column Widths: 0";1" (id number; teacher's Name)

I have tried:
DoCmd.RunSQL ("UPDATE tblStudent SET fldTeacher1 = " & Val(txtID) & "
WHERE fldID = " & gintStudentID & ";")

All it does is place the id # in the field and not display the
teacher's name in fldTeacher1 after the command was run.

Can someone please tell me how I am to update tblStudent.fldTeacher1
with a value from tblTeacher through a sql statement in vba? I really
could use help other than the table should not use lookup fields.

Apr 22 '06 #2

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

Similar topics

2
by: Tony Johnson | last post by:
Hello, I have a form that has a lot of fields. It is based on a one table. I have company information and then a description. I have to continually type in the description and it is a...
3
by: my-wings | last post by:
I've been reading about how evil Lookup fields in tables are, but I've got to be missing something really basic. I know this subject has been covered before, because I've just spent an hour or two...
1
by: Zachary Turner | last post by:
I want to make a Lookup Field based on another Lookup field. In other words, I have this table A with two fields: ID and Name, where ID is an Autonumber and Name is a friendly name. Then I have a...
3
by: google | last post by:
I have a database with four table. In one of the tables, I use about five lookup fields to get populate their dropdown list. I have read that lookup fields are really bad and may cause problems...
3
by: dbuchanan | last post by:
Hello, (Windows forms - SQL Server) I fill my datagrid with a stored procedure that includes relationships to lookup tables so that users can see the values of the combobox selections rather...
3
by: jpr | last post by:
Hello, I know that this is not the rule but need some help. My datbase has three tables: MASTER TEMPLATES FORMS I have a form which is based on a table named MASTER. I have a primary key...
5
by: Stephen Plotnick | last post by:
I'm very new to VB.NET 2003 Here is what I have accomplished: MainSelectForm - Selects an item In a public class I pass a DataViewRow to ItemInformation1 Form ItemInformation2 Form
11
by: Paul H | last post by:
Suppose I have a table called tblPeople and I want a field to illustrate whether each person prefers cats or dogs. I could do it one of three ways. 1. A plain text field Create a text field in...
6
by: wellsfargouser | last post by:
Hey everyone, this is driving me crazy. I have a table which lists all the files users have on the server. This table is called risklist. It lists the pathname and size. The goal is to make a form...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.