Where Condition Syntax

fikile

New member
Local time
Today, 05:48
Joined
Aug 29, 2012
Messages
5
I have a Where Condition in an OnClick Open Form that I want to change from:
="[ID]=" & [ID]
to something with multiple criteria as in
="[ID]=" & [ID] AND "[Date]=" & [Date]
This syntax isn't working in that it gives me the correct year but gives the same ID (1st in the table) no matter which ID I specify. Suggestions?
 
Code:
="[ID]=" & Me.[ID] " AND [fldDate]=" & Format(Me.[ctrlDate],"/#mm\/dd\/yyyy\#")

You have the string structure incorrect. The quotes are in the wrong place. (Use a variable and Debug.Print to debug this kind of error.)

The date needs to be delimited and in the right format.

Date is a reserved word and should be avoided.

The current class object (Me) should be included in a reference to a control.
 
Galaxion, thank you for your response. Some more questions for you if you don't mind:
Where do I access debug.print?

When I substitute variable names in the syntax you provided, i.e.
[FONT=&quot]="[ID]=" & Me.[ID] " AND [Dot_Year]=" & Format(Me.[Session Date],"/#mm\/dd\/yyyy\#")
[/FONT]​
... I got the message
The ‘OpenForm’ macro action has an invalid value for the ‘Where Condition’ argument
Got the same message with several different variations of the syntax. Also tried adding the form & subform name to no avail. Now I'm playing with switching the embedded macro to an event procedure using either stLinkCriteria or Where Condition. Still grasping at straws. I appreciate any suggestions anyone has.

[FONT=&quot][/FONT]
 
So this syntax is working in terms of selecting the right ID & the right year:
[ID]=[Forms]![frm Jumping Frog]![id] And [dot_year]=Format([Forms]![frm Jumping Frog]![Session Date],"yyyy")
I have locked the id & dot_year but the problem now is that for a year that does not already exist in the table corresponding with the sub-form, Access gives a form with id & dot_year blank. I would like to have Access autofill those two fields from [frm Jumping Frog]. Any ideas?
 
I have in a form „Text Field 1“ and „Text field 2“,



I want to genereate a report containing records based on entries in these fields.
I have in a Form on Click Macro/Open report/Where Condition:
Code:
="[ID]= " & [Text Field 1] & " AND [ID]= " & [Text Field 2]


It is not working.
Any suggestions?


Thank you in advance.
 
I don't know a lot about syntax but wonder whether the logic of 'AND' should be 'OR' because the ID for a single record cannot simultaneously =Text1 and =Text2.
 

Users who are viewing this thread

Back
Top Bottom