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

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 1649
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_AfterUpdate()
If Nz(Trim(FilmID),"") = "" then Exit Sub
Me!txtFilmName = Nz(DLookup("FilmName","tblFilm","FilmID = " _
& Me!FilmID),"Film Not Found")
Me!txtFilmType = Nz(DLookup("FilmType","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********@gmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.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_AfterUpdate()
If Nz(Trim(FilmID),"") = "" then Exit Sub
Me!txtFilmName = Nz(DLookup("FilmName","tblFilm","FilmID = " _
& Me!FilmID),"Film Not Found")
Me!txtFilmType = Nz(DLookup("FilmType","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
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...
3
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...
14
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 ;...
2
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...
2
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...
1
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...
1
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...
13
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...
3
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...
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:
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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,...
0
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...

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.