Populate Textbox with SQL query

  • Thread starter Thread starter adonai_comp
  • Start date Start date
A

adonai_comp

Guest
Using a command button, I would like to execute code that will populate a textbox based on a SQL query. I will try to explain what I have already done, but please be warned that I am NOT a programmer by nature...

The user will be prompted with an InputBox to input their password, which is stored in the Password field of the table Employees. That password will be stored in a variable that will then be used as the criteria for the SQL query. The SQL query will find their corresponding EmployeeName in the Employees table.

I can get this far. I need help taking that SQL query result, storing it in a variable (I assume), and using it as the text value of a textbox.

If I have not been clear, please let me know. I can post any files if necessary. Any help that could be given would be so much appreciated.

Thanks.
 
I think you can do a "DLookup" function within your text box. Put an unbound text box on a form. In the control source of the text box, put
=DLookup("EmployeeName", "Employees", "Password = " & yourPasswordVariableName). The syntax will need to be tweeked, but basicall you are telling the field to display the Employee name from the Employee table where the password = your variable.
 
That's it!!

Poet1234, you are a genius! Well to me you are anyway. That was what I needed. I am still learning all the commands (or whatever programmers call the keywords). Works beautifully. Thanks for the tip!

:)
 

Users who are viewing this thread

Back
Top Bottom