Dlookup in form returning #Error (1 Viewer)

ozziestockton

New member
Local time
Today, 06:22
Joined
Jul 19, 2012
Messages
2
I'm new to forms and am revamping a company database. it's a small database and i just want to populate enrollment automatically after the user selects a school district from a drop down. Enrollment is just in another table, so it seems like it should be easy, but I can't figure it out. I get #Error in the text box. I've googled to death with no fix.

This is what I have in the Control Source:

=DLookUp("ReportedEnrollment","dbo_Tasb_Account_View","Account = " & [Forms]![Data Entry Form]![DistrictID])

I have Office 2010, but this database is still an .mdb (could that be a problem?)

Thanks for your help!
 

G37Sam

Registered User.
Local time
Today, 15:22
Joined
Apr 23, 2008
Messages
454
Why do you need a dlookup in a control source of a text box?

Either run dlookup in VBA on open or on current OR change the textbox to a combo box and embed a query in its row source.
 

boblarson

Smeghead
Local time
Today, 04:22
Joined
Jan 12, 2001
Messages
32,059
1. Is Account text or numeric?

2. Is DistrictID really the item that would be in the Account field?

3. Is the DistrictID combo returning the right info for Account? It would be returning what field which is set to be the bound field in the combo's properties (usually set to 1 for the first field in the rowsource).
 

ozziestockton

New member
Local time
Today, 06:22
Joined
Jul 19, 2012
Messages
2
Account is text, so added the necessary quotes and that fixed it. Thanks for pointing that out! Now i just need to see if I can get it to write to the table. The drop down is working now though!

Thanks for the help boblarson.

G37Sam, I'm new to VBA, so I will give that a shot next time. Thanks.
 

boblarson

Smeghead
Local time
Today, 04:22
Joined
Jan 12, 2001
Messages
32,059
From your description of this, I will state, you shouldn't be populating a table with data that already exists elsewhere. Just use a query when you need to get that information. The DLookup should only be letting you see what the associated data is anyway.
 

Users who are viewing this thread

Top Bottom