call query to populate txtbox

  • Thread starter pclis007 via AccessMonster.com
  • Start date
P

pclis007 via AccessMonster.com

My situation: IE: My form is comprised of a cmd button grid, A1 thru D10.
When you click on cmdButton A1, it populates a cell ([txtGrid]) on the form
with the value "A1". I have a standalone query ([qryCellProduct]) that
bases it's filter off of the contents of [txtGrid], using the following
statement in the [CellLocation] field:

[Forms]![frmVendingMachine]![txtGrid]

The results of the query show data including a product assigned to that
cell, and the cell grid number.
What I need to do is somehow populate [txtProduct] on the same form with the
results of the query. Note: The query cannot get results until after that
cmdButton is clicked. I don't know how to call a query using VBA, otherwise
I would do that in the OnClick event of the cmdButton, IE:

Private Sub cmdA1_Click()

Me!txtGrid.Value = "A1"

If IsNull(txtGrid) = False Then
Me!txtProduct.Value = qryCellProduct!product



Any ideas?

Thanks,

Perry
 
G

Guest

If the query return only one record, use DlookUp to return the value from the
query

Me!txtProduct = DLookUp("product","qryCellProduct")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top