Performing an SQL query in VBA



I need to perform a SQL query in VBA and display the result in a
textbox. First let me explain my situation. I have a form with two
text boxes, one is called txtLName and the other txtNum. I also have a
table called People. I want to run the following query in the
txtLName_Change() event and display the result in txtNum.

SELECT COUNT(LName) AS Num FROM People WHERE LName LIKE
'Me![txtLName]*';

Eventually the value returned will go to an if statement, but for now
just getting it to a textbox is great. Thank you, Jon

.



Relevant Pages

  • RE: Expression Builder basic question on syntax / Or / how to incorpor
    ... it is always best to avoid unnecessary hits on the database. ... Use only the control name without the Me. ... runtime error on the textbox. ... This SQL query works, ...
    (microsoft.public.access.formscoding)
  • RE: search for file path, please help
    ... "ListBox1" is populated with every file in that sub-directory. ... in the BkLocation textbox. ... The BkLocation text box would display something like ...
    (microsoft.public.access.formscoding)
  • RE: search for file path, please help
    ... "ListBox1" is populated with every file in that sub-directory. ... in the BkLocation textbox. ... The BkLocation text box would display something like ...
    (microsoft.public.access.formscoding)
  • RE: How to lookup the corresponding field?
    ... But I was hoping to use the Category textbox still ... because I just want it to display the value, and not to give user the choice ... > tblType need only a numeric field in which to store the ID, ... >> But the CategoryID textbox in frmType still displays CategoryID values, ...
    (microsoft.public.access.forms)
  • RE: search for file path, please help
    ... "ListBox1" is populated with every file in that sub-directory. ... in the BkLocation textbox. ... The BkLocation text box would display something like ...
    (microsoft.public.access.formscoding)