Passing FORM value to my Query inside VBA

  • Thread starter Thread starter vikash.verma
  • Start date Start date
V

vikash.verma

Hi All
I have written an application where in i need to call a FORM,MACRO and then
a VBA.
Inside a Macro an Action RunCode is written which in turn calls a VBA code
written below

intValue = DLookup("NumCount", "Query1Test")

This query has a Where condition

Query1Test:
SELECT Count(*) AS NumCount FROM DelMastTemp
WHERE (((DelMastTemp.CustomerID)=Forms!Forms_DAR!Driver_Control.Value) AND
(DelMastTemp.StartDate=Forms!Forms_DAR!StartDate_Control.Value));

But this Where condition value is being passed frm my FORM to this Query.
If i run the Query alone i get a Parameter Value in that i pass the data nd
i get the Resul.

But when i run through this Form it throws an exception.I know the reason
behind it .The VALUE in the query is not being passed from the FORM.How nd
where should i give my WHERE Condition so that my query works.

Shall i have to give the where condition inside the DLookup() or HOW?

I am hoping to receive mails frm u all.

Regards
Vikash
 
Hi Vikash,
In the criteria row of the query in the field whose
value you need from the form.. put
Forms!YourForm!FormsField
If the field name has a space in it, you will need to
enclose it in brackets.

Hope This Helps
 
Hi Art,
Infact i am calling the query inside the DLookUp() fn.The Where condition has to be specified.


intCustCount = DLookup("NumCount", "Query1Test", " [StartDate]=#8/22/2003#")

But it gives me an Error even by using
1. Static Data (It says U cancelled the Prevoius operation,Run time Error 2001)
2. By using [StartDate]= Forms!Form_DAR!StartDate.Value(The Error says cant find Form_DAR)

I need to get the count of the from my DLookUp() fn if there are no reocrds for that specific date i generate a MsgBox.

I am waiting for ur mail
 
Hi Art,
Infact i am calling the query inside the DLookUp() fn.The Where condition has to be specified.


intCustCount = DLookup("NumCount", "Query1Test", " [StartDate]=#8/22/2003#")

But it gives me an Error even by using
1. Static Data (It says U cancelled the Prevoius operation,Run time Error 2001)
2. By using [StartDate]= Forms!Form_DAR!StartDate.Value(The Error says cant find Form_DAR)

I need to get the count of the from my DLookUp() fn if there are no reocrds for that specific date i generate a MsgBox.

I am waiting for ur mail
 
Back
Top