473,770 Members | 1,826 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how do i get access to automatically fill in fields?

DP
hi,

i have created a video rental database system. i have created a customer
form, and a film form.

i related all the tables, with;

tblCustomer has membershipID, which is primary and autonumber,
tblFilm has FilmID, which is primary and autonumber,
tblFilmRental , which has RentalID, CsutomerID, and FilmID

tbl customer is related to tblFilmRentals, and tblFilm is related to
tblFilmRental.

i've created a query, but i want it so that, when a film is rented, through
using the ID, i want it to display the film name and type in the
corresponding fields respectively. in the film rental form (subform).

i've done this before, on some other database, where it fills in the fields
automatically, but i cant get it to work on this.

any1 got an idea? i'm probably missing something obviouse.
TIA.

devin

Feb 2 '06 #1
2 2205
Devin:

You can add a couple of unbound fields to your form, and name them
txtFilmName & txtFilmType. Then, on the FilmID AfterUpdate Event, put
something like this (Air Code):

Private Sub FilmID_AfterUpd ate()
If Nz(Trim(FilmID) ,"") = "" then Exit Sub
Me!txtFilmName = Nz(DLookup("Fil mName","tblFilm ","FilmID = " _
& Me!FilmID),"Fil m Not Found")
Me!txtFilmType = Nz(DLookup("Fil mType","tblFilm ","FilmID = " _
& Me!FilmID),"")
End Sub

Now, you should be aware that every DLookup causes a separate query to
your database, which *can* be slow if you have lots of records...if
that is the case, let me know & I will help you with a more efficient
method.

HTH,
Jana

Feb 2 '06 #2
DP
thanx for the help,

i've sorted it, without using any code.

i basically created that query, but used fields from the film table, so now
eveytime a number is inserted as a film id, the rest of the fields are
automatically updated.

thanx for the help.

dev

"Jana" <Ba********@gma il.com> wrote in message
news:11******** **************@ o13g2000cwo.goo glegroups.com.. .
Devin:

You can add a couple of unbound fields to your form, and name them
txtFilmName & txtFilmType. Then, on the FilmID AfterUpdate Event, put
something like this (Air Code):

Private Sub FilmID_AfterUpd ate()
If Nz(Trim(FilmID) ,"") = "" then Exit Sub
Me!txtFilmName = Nz(DLookup("Fil mName","tblFilm ","FilmID = " _
& Me!FilmID),"Fil m Not Found")
Me!txtFilmType = Nz(DLookup("Fil mType","tblFilm ","FilmID = " _
& Me!FilmID),"")
End Sub

Now, you should be aware that every DLookup causes a separate query to
your database, which *can* be slow if you have lots of records...if
that is the case, let me know & I will help you with a more efficient
method.

HTH,
Jana

Feb 3 '06 #3

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

Similar topics

5
7357
by: rob | last post by:
Hi to all. I am pretty new to using Access and am having a problem I hope someone can help me with. I want to access a MS-Access database from a web page. I have managed to get it "sort" of working using MS-Access's 'data access page' function as it were. This creates a web page that is linked to a database table. The problem that I have is that if data in the dbase is changed, it does not immediately reflect
3
1515
by: Pasquale | last post by:
I have a database used for contact information and another for event information. As part of the event database, we would like to keep record of the people that are attending a certain event. These are the same people who are in the contact database. Using a MS Access form in the event database, is there a way to select the names from the contact database in the Name field when adding who is attending an event, rather than typing their...
14
3111
by: alwayshouston | last post by:
Hi All! I am working on this very small database and I am confused in the designing a simple form. I only have three tables in the database. First Table: tblExpense Columns: ExpenseID ; ExpenseType Data: 1 ; FOOD 2 ; AIRLINE 3 ; FARE
2
1435
by: k.bel | last post by:
The table I created is very easy: it consists of one field "Nomen" (datatype 'text' size 50) and 10 fields m1 to m10 datatype 'text' size 3. Now, having an array of some records with different "Nomen" and after that to fill m1 of the first record with 1 and m1 of the second with 2 by using the "down"-key for going forward, MS-ACCESS will fill m1 of the following records automatically with 3; 4; 5;.... when only using the "down"-key. The...
2
4053
by: jho | last post by:
hello, I have a pricing sheet form and have the following fields in one row: SKU DESC UNIT PRICE QTY PRICE I want to select the sku in the form and have the corresponding desc and unit price fill in automatically and then manually input the qty
1
408
by: moorebj | last post by:
I am having trouble writing a SELECT query. I have a "Customer" table with "Customer Name", "Street Address" and "Suburb, State, Post Code" fields. On a form I would like to be able to enter in the "Customer Name" and automatically fill in the "Street Address" and "Suburb, State, Post Code" fields from this table. All of the fields on the form are COMBO boxes. Any help would be greatly appreciated.
1
2462
by: cclayton000 | last post by:
Does anyone have a basic example of a script that can automatically fill fields in a subform? Here is the scenario: I have a main form for a Sample Lot and I have added some side-fields (not bound to any table) that asks basic information: Number of Samples (x), Quantity, Unit of Measure, Location, Tray...I would then like a button that triggers a script to automatically create the Sample Details (subform) that is autonumbered and then...
13
8882
by: Terry Olsen | last post by:
I'm using OleDb to connect with an Access Database. I have anywhere from 10 to over 100 records that I need to either INSERT if the PK doesn't exist or UPDATE if the PK does exist, all in a single transaction. Does anyone have an SQL statement I can throw at it that would accomplish this? If I can't figure out how to do it, I'm going to have to send two discreet SQL commands for each record which will take infinitely longer than a...
3
1414
by: jillinsky | last post by:
Wondering is this is possible - I have 2 tables. One is categories, and has catid, catname, hashighercat, and ...I can't think of the 4th one, but it isn't needed anyway. There are 40 categories, and about 1400 subcats. the categories are numbered 1-40, and the rest have their numbers - all of these are in the same field - catid. You can tell the categories from the subcategories by the field hashighercat - the 40 categories are null...
0
9617
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10257
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
10099
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
10037
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,...
1
7456
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
6710
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
5354
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
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3609
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.