sql script not returning value from form

  • Thread starter Thread starter Rashar Sharro via AccessMonster.com
  • Start date Start date
R

Rashar Sharro via AccessMonster.com

Hi,

I have a form that when you select a customer from a combo box, a hidden
textbox called txtCust_Number on the same form is then populated with the
customers number.

On the same form, I have a navigation pane that when I click on an item
(Products), it calls this query:

Case 101
ChForm.SourceObject = "frmProducts"
ChForm.Form.RecordSource = "SELECT * FROM qryProducts"

My question is, how can I re-write the sql script to say, select all from
qryProducts where the Cust_Number from qryProducts = txtCust_Number from
the form?

Thank you.
 
Hi Rashar,

Try revising the sql to:

SELECT * FROM qryProducts WHERE Cust_Number =
Forms![YourFormName]![txtCust_Number]

but insert the actual name of the form containing the field txtCust_Number
(I didn't see that form name specified in your post, although I may have
missed it)

HTH, Ted Allen
 
Hi Ted, Thanks for your reply...That almost works. My problem now is trying
to pass the value from one form to my other form (Forms![YourFormName]!
[txtCust_Number])

Again, thanks.
 
Hi Rashar,

You should be able to use the AfterUpdate event of the control on your form
to set the value in another form.

In the AfterUpate event of the source control, you would just enter some
code like:

Forms!YourDestinationForm!YourDestinationControl = Me.YourSourceControl

Hope that helps,

Ted Allen
 
Back
Top