Help with simple SQL statement

  • Thread starter Thread starter Pharoh
  • Start date Start date
P

Pharoh

I'm trying to genereate a report using a Select Query. I want the
report to bring up only the one record as identified by the ID (Primary
Key) but I don't know how to pass that in as a parameter.

SELECT [Work Log Entry].ID, [Work Log Entry].[date started], [Work Log
Entry].[date closed], [Work Log Entry].Application, [Work Log
Entry].Caller, [Work Log Entry].[PIR #], [Work Log Entry].[ICT #],
[Work Log Entry].Notes, [Work Log Entry].[File(s)]
FROM [Work Log Entry]
WHERE [Work Log Entry].ID = ??? <---- value in field
 
Add a sentence that you want the user to be prompt with as the criteria, in
square brackets

e.g

SELECT [Work Log Entry].ID, [Work Log Entry].[date started], [Work Log
Entry].[date closed], [Work Log Entry].Application, [Work Log
Entry].Caller, [Work Log Entry].[PIR #], [Work Log Entry].[ICT #],
[Work Log Entry].Notes, [Work Log Entry].[File(s)]
FROM [Work Log Entry]
WHERE [Work Log Entry].ID = [Please select and ID]
 
replace the ??? with [Enter Id]
I'm trying to genereate a report using a Select Query. I want the
report to bring up only the one record as identified by the ID (Primary
Key) but I don't know how to pass that in as a parameter.

SELECT [Work Log Entry].ID, [Work Log Entry].[date started], [Work Log
Entry].[date closed], [Work Log Entry].Application, [Work Log
Entry].Caller, [Work Log Entry].[PIR #], [Work Log Entry].[ICT #],
[Work Log Entry].Notes, [Work Log Entry].[File(s)]
FROM [Work Log Entry]
WHERE [Work Log Entry].ID = ??? <---- value in field
 
thanks for the help guys..:)

I think I may have worded that wrong. When the form loads, it displays
a record with an ID number. I want to create a report using that ID
number so that it only displays that record in the report.
 
so far this SORT of works...

trying to find a way to change the WHERE claus so that it uses a number
already in the field to identify the recordf and not just any record
with a number in the field.

PARAMETERS strId IEEEDouble;
SELECT [Work Log Entry].[ID], [Work Log Entry].[date started], [Work
Log Entry].[date closed], [Work Log Entry].[Application], [Work Log
Entry].[Caller], [Work Log Entry].[PIR #], [Work Log Entry].[ICT #],
[Work Log Entry].[Notes], [Work Log Entry].[File(s)]
FROM [Work Log Entry]
WHERE ([Work Log Entry].[ID]=strId);
 
Try

SELECT [Work Log Entry].ID, [Work Log Entry].[date started], [Work Log
Entry].[date closed], [Work Log Entry].Application, [Work Log
Entry].Caller, [Work Log Entry].[PIR #], [Work Log Entry].[ICT #],
[Work Log Entry].Notes, [Work Log Entry].[File(s)]
FROM [Work Log Entry]
WHERE [Work Log Entry].ID = Forms![FormName]![FieldNameInForm]
 
Back
Top