473,837 Members | 1,783 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.fldT eacher1
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 4024
> 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*******@gmai l.com> wrote in message
news:11******** **************@ i39g2000cwa.goo glegroups.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.fldT eacher1
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
1939
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 duplication of work because I have the description written in another table. I want the description field to be updated automatically so I dont have to keep typing it in for the particular vendor. I can build a query but it would affect other reports...
3
2932
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 reading about it on google, but there is something I still don't understand, and I'm hoping someone will be willing to explain it to me in small words. Let's say I have a table for addresses, and it includes a field for state. What I would...
1
3377
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 table B which links to A via a Lookup Field so that I can select the friendly name from combo box. Now, I want to have a table C which links to table B via a lookup field, and only displays the items which are selected in some combo box of some...
3
10681
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 that are hard to find. The main problem I am having right now is that I have a report that is sorted by one of these lookup fields and it only displays the record's ID number. When I add the source table to the query it makes several records...
3
2295
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 than the key value that are stored in the table. It works well if the comboboxes are selected when the row is created.
3
3548
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 set to autonumber and a field SSN which I would
5
2603
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
2664
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 tblPeople called PreferredPet. 2. A lookup field that stores text values. Create a text field in tblPeople called PreferredPetID and use it to lookup an identical text field in tblPreferredPets.
6
2152
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 that users can open up, filter for their user id and choose one of four options for each individual record. I've built a query that runs based on a command button in the form that filters for the userid in a combo box on that same...
0
9682
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10566
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
10623
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
9401
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
7806
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
7001
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5669
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
5848
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4474
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.