Sunday 15 June 2014

vba - How to run query based on information from specific customer? -


I have a form that is tabbed and displays all the information from my main table, I double click on a record I want to be able to (if possible, a record selector), then run a query based on the specific values ​​of that specific customer.

Right now, I can click on it to run a record selector and normal query. However, I want to be able to separate the query on which the user is clicked. Based on the double click on the record selector I have the code to run the query.

  Private Sub Form_DblClick (cancel as integer) DoCmd.OpenQuery "Contributions" End Sub   

For example, if the product number is 01 and The check date for customer 1 is 06/18/13, so I want to use this information for the criteria in my query.

I'm not really sure that you can run a query based on information from a record selector. If not, how can I go further about this? I started VBA last week, so I am a newbie, but I have other coding experience, so I am learning very quickly. Any help is appreciated! Instead of opening the query, I recommend using the recommendation as a record in a form.

The source gives you more flexibility on the appearance & amp; material.

To open the form, try. This allows you to include it where conditions and filters want to get specific records for you. Links are included in the example (and if that's not enough, just ask for more Google or here).

Edit

Using your case as an example, call your main form FRMA and your query result FrmB < / Code>. In both your record sources (which can be tables or queries), your product number is called ProdNum and check date is CheckDate (no need to call them Is the same thing in both the sources, but I am trying to keep it simple)

In FRMA, add a command button in the extension section. This command button will have one click event.Try this code: / P>

  DoCmd.OpenForm "FrmB", ", [ProdNum] =" & amp; Me Prodenam & amp; "And [checkdate] = #" & amp; me. Check & amp; "#"   

In this code, I have added line breaks for readability (you should take them out). Also, I'm assuming that the Prodenam field is a number type and the checkdate field type is date so that's why I'm in the # symbols around it, the Me.ProdNum field value is < Code> FRMA and passing that value as a condition for FrmB.

No comments:

Post a Comment