Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Complicated Query Issue...Helpp!!

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Here is the problem. I have two forms. My main form is called General. and then I have another form called "Victim" I placed "Victim" as a subform into General and now I am trying to create a query. Here is the problem. I have that SQL code down below in a query called "Victim Query" the problem that is arising is when the user is in the General form (which contains the Victim subform) and types in information for Victim to be searched a box pops up that says "Enter Parameter Value" Forms.Victim.Last Name. I do not know why it is doing this. When I open the Victim Form by itself the query works fine, the problem only happens when I try to run the query from the General form. I have to be able to run the query within the General Form so if anyone has any idea how to fix the problem it would be greatly appreciated

SELECT [Victim].[Last Name], [Victim].[First Name], [Victim].[Res Add], [Victim].[Res Phn], [Victim].[Bus Add], [Victim].[Bus Phn], [Victim].[Race], [Victim].[Sex], [Victim].[Age], [Victim].[Occupation]
FROM Victim

WHERE ([Victim].[Last Name]=[forms].[Victim].[Last Name] Or [forms].[Victim].[Last Name] Is Null) and ([Victim].[First Name]=[forms].[Victim].[First Name] or [forms].[Victim].[First Name] is Null);
 
If this is a direct transcript of your SQL then the problem is being caused by your notation. Use ! instead of . and things should work fine.

HTH

Craig
 
I made the changes as prescribed and it stilll doesn't work :( I have no idea what is going on. My subform "Victim" is in my General report (it is in a Tab Control because there are other subforms within the general page) So below is the query change. When I am in my General form and I run the query it asks me to enter parameter values for Forms!Victim!Last Name and Forms!Victim!First Name. If I just hit "Ok" through both of them without providing any data then all my records appear. But if I type in any data for either of the fields than the table Select Query Table which appears is blank. The same thing happens if I open the "Victim" form by itself without going through the "General" form. If I enter data into the fields and hit the query button then no data appears, but if I do not enter any data everything shows up.

FROM Victim

WHERE ([Victim]![Last Name]=[forms]![Victim]![Last Name] Or [forms]![Victim]![Last Name] Is Null) And ([Victim]![First Name]=[forms]![Victim]![First Name] Or [forms]![Victim]![First Name] Is Null);
 
I made the changes as prescribed and it stilll doesn't work :( I have no idea what is going on. My subform "Victim" is in my General report (it is in a Tab Control because there are other subforms within the general page) So below is the query change. When I am in my General form and I run the query it asks me to enter parameter values for Forms!Victim!Last Name and Forms!Victim!First Name. If I just hit "Ok" through both of them without providing any data then all my records appear. But if I type in any data for either of the fields than the table Select Query Table which appears is blank. The same thing happens if I open the "Victim" form by itself without going through the "General" form. If I enter data into the fields and hit the query button then no data appears, but if I do not enter any data everything shows up.

FROM Victim

WHERE ([Victim]![Last Name]=[forms]![Victim]![Last Name] Or [forms]![Victim]![Last Name] Is Null) And ([Victim]![First Name]=[forms]![Victim]![First Name] Or [forms]![Victim]![First Name] Is Null);
 
If it is still asking for the parameters then the fields can't exist. Can you check that your field names are correct?

Craig
 
All Field names seem to be correct...Is there anyway I can send you the query and the form and you may be able to look over it and see the errors that I cannot pick up on
 
A shorter way to try and solve your problem would be to use the query builder and run the queries from there. The Access wizards are pretty good with syntax. If it works from there then just copy and paste the code you have developed from the SQL view(while in query builder) into your form.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top