Alter selection criteria of a query from a form

Yippiekaiaii

Registered User.
Local time
Today, 20:41
Joined
Mar 25, 2013
Messages
21
Hello All

I have a form that runs off a query that displays further details of a record in a datasheet when you double click on a row.

The query itself has criteria that looks at the open form and selects the correct record.

My question is can you change the results of the query either using vba or a built in feature of access without having to use a separate query.

The selection criteria in the query is:

Forms]![Main]![Ordering-Supplier]![Ordering-Order List].[Form]![suppOrderID]

Basically I want to override the resulting data with another record when I run an event on the form.

Sorry if i haven't explained this very well.
 
In a regular module (a public one) create this code:

Code:
Public MyVar As Long ' I assume that suppOrderID is Long type

Public Function GetCriteria As Long
   GetCriteria = MyVar
End Function
Switch to Query Design View and replace your actual Criteria with GetCriteria()

In the code of your form, manage to update the value for MyVar as you need before to run the query.

Good luck !
 
Thank you for the reply.

How do i create a regular/public module?
 

Users who are viewing this thread

Back
Top Bottom