You are here:

Using MS Access/Using SQL to populate a field?

Advertisement


Question
Hi Scott,

I have some SQL which works fine in a query, and gives me accurate results.  I was just wondering whether I could use that SQL in code behind a form to populate a form field upon "AfterUpdate" or "OnClick" of a listbox?

I have tried a few options, but does not want to work lol.   

Would save me a squillion hours of time if it's possible, as I am hoping to use it as the basis for many dynamic answers on one form (as summary, so to speak).

thanks in anticipation
Pete

Answer
Apologize for the late reply, just saw this.

The answer is to do a DLookup. If you have a canned query you can use a dLookup to return a value from it.

Alternatively, you can open a recordset with the query then assign the value of a filed to the form control.

Hope this helps,
scott<>

Using MS Access

All Answers


Answers by Expert:


Ask Experts

Volunteer


Scottgem

Expertise

I can answer almost all types of questions relating to Microsoft Access usage and application design. My strengths are database and interface design.

Experience

I've been designing databases for over 25 years working with dBase, FoxPro, Approach and Access.

Organizations
Author of Microsoft Office Access 2007 VBA
Techncial Editor for Special Edition Using Microsoft Access 2007 and Access 2007 Forms, Reports & Queries From Que Publishing

Education/Credentials
Brooklyn College BA

©2016 About.com. All rights reserved.