The Dlookup command doesn't work... (1 Viewer)

D

Deegan

Guest
I have a problem.
Let's say for example I have a table with three (3) fields.

Car:
License Plate:
State:

I am trying to allow users to fill this form out. Some cars are listed in a separate table with their corresponding license plates and states. However, some are not in the database. How can I set up my form so that one can either select their car from the drop down list and have it fill in the L.P. and state fields OR fill in the Car, L.P. and State fields manually.

USING DLOOKUP DOES NOT ALLOW FOR USERS TO MANIPULATE DATA IN DLOOKUP FIELDS! (NOR DOES DLOOKUP STORE THE DATA IN THE TABLE IN WHICH MY FORM IS BASED - IT JUST RECALLS THE DATA FROM ANOTHER TABLE)
 
J

jgaweda

Guest
i just set up a series of databases and i have a similar problem getting Dlookup to work. I have a form based on a table, i also have a linked table with stored data such as contract name, which i enter matching contract numbers i want access to bring up contract number on the form automatically. i keep getting #error on the form. if you get any help please include me
 

GMC

Registered User.
Local time
Today, 13:42
Joined
Nov 1, 1999
Messages
10
Deegan,

Try creating controls on your form which are bound to the appropriate fields in your underlying table. Then, use the DLookup command in code.

E.g.
Controls: [t_license]; [t_state]
Fields on form: [t_license] bound to 'license' in underlying table; [t_state] bound to 'state'

Ensure that 'Limit to List' = No for the drop-down list and on the AfterUpdate event insert code something like:

[t_license] = DLookup("[license]","Cars","[Car]= '" & Forms![myform]![mychoice] & "'")
[t_state] = DLookup("[state]","Cars","[car]= '" & Forms![myform]![mychoice] & "'")

BUT, it sounds to me like you may have the logic back to front. Assuming that License Plate is a unique field, why not have the user either select a License plate from a drop-down list or enter their details manually?? Only a suggestion.

Hope this helps

Grant
 

Melody

Registered User.
Local time
Today, 13:42
Joined
Aug 11, 2000
Messages
47
I'm having a problem with DLookup also. I have a main form (FormI) and a linked form (FormII). I have a CustomerID field on FormI. This field is in the Customers table. I want to put a field on FormII that looks up this value. However, I want the CustomerID on FormII to match the CustomerID on Form I (A way of linking these forms). I've tried doing this using the Lookup tab within the table itself and it's not working, so I'm onto this path. Here's the expression I put into the control:

=DLookUp("[CustomerID]","Customers Table")

I've tried adding some criteria to this but it's not working. Does anybody know how I can pull this value into FormII, and have FormII match FormI, as far as this CustomerID field???????

Thanks!!!!
 

Jack Cowley

Registered User.
Local time
Today, 13:42
Joined
Aug 7, 2000
Messages
2,639
Melody -

If FormI is open while FormII is open then putting [Forms]![FormII]![CustomerID] = [Forms]![FormI]![CustomerID] as the Control Source for the CustomerID on FormII will display the CustomerID from FormI on FormII. You may need to put the Code in the On Current event of FormII depending on how you are using FormII.

If I have completely missed the boat here is an article on how to synchronize two forms...
http://support.microsoft.com/support/kb/articles/Q149/9/40.asp?LN=EN-US&SD=gn&FR=0&qry=q149940&rnk=1&src=DHCS_MSPSS_gn_SRCH&SPR=ACC97
 

Users who are viewing this thread

Top Bottom