By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,374 Members | 2,993 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,374 IT Pros & Developers. It's quick & easy.

Form Searching

P: 48
I am trying to create a search from a form but am having trouble getting data returned.

- I have a combo box, CboTitle Search that I select the criteria from.
- I have a search button, cmdSearch, that is looking through a query of submitted work when clicked.
- I want to compare what is selected in the combo box to the rows in the query and pull all the data in the query for the titles that match.
- I have tried creating a separate query for this process and using the OnClick Event Procedure to run it but I am not getting any results.
[SQL Query CODE]
Expand|Select|Wrap|Line Numbers
  1. SELECT Created_Submitted_Query.Title, Created_Submitted_Query.[Year Created], Created_Submitted_Query.Submitted, Created_Submitted_Query.[Submitted To], Created_Submitted_Query.Website, Created_Submitted_Query.Accepted, Created_Submitted_Query.Date, Created_Submitted_Query.Type
  2. FROM Created_Submitted_Query
  3. WHERE ((([Forms]![Records_Search]![CboTitleSearch])=[Created_Submitted_Query].[Title]))
  4. GROUP BY Created_Submitted_Query.Title, Created_Submitted_Query.[Year Created], Created_Submitted_Query.Submitted, Created_Submitted_Query.[Submitted To], Created_Submitted_Query.Website, Created_Submitted_Query.Accepted, Created_Submitted_Query.Date, Created_Submitted_Query.Type;
[SQL Query CODE]

Ultimately I would like to have the results appear as a sub-form on the bottom half of my search form instead of opening another screen. However, I can fight that battle later if necessary.

Unfortunately for me I am not a programmer and am just trying to teach myself how to do some things. Any help on this would be greatly appreciated.

Thanks,
Doug
Apr 18 '08 #1
Share this Question
Share on Google+
2 Replies


P: 48
Hello,

I actually had the query, Records Search Query, retunring data now but only when I ran it direclty and not by using the command button. Here is the code for the command button.

[Command Button Code]
Expand|Select|Wrap|Line Numbers
  1. Private Sub CmdSearch_Click()
  2. On Error GoTo Err_CmdSearch_Click
  3.  
  4.     Dim stDocName As String
  5.  
  6.     stDocName = "Records Search Query"
  7.     DoCmd.OpenQuery stDocName, acNormal, acEdit
  8.  
  9.  
  10. Exit_CmdSearch_Click:
  11.     Exit Sub
  12.  
  13. Err_CmdSearch_Click:
  14.     MsgBox Err.Description
  15.     Resume Exit_CmdSearch_Click
  16.  
  17. End Sub
[Command Button Code]

Do I need an IF statement of soemthing in the code above? After testing it in the form again I started receiving no returns regardless of how I tried it. If I close Access and come back in I am again able to receive data back after getting prompted with a dialog box to enter a title.
Apr 18 '08 #2

NeoPa
Expert Mod 15k+
P: 31,494
Doug, Your question seems a little complex. Check out Example Filtering on a Form and let us know if you're still having problems. Then, if we need to, we can go into more detail.

PS. Note the use of the [ CODE ] tags. They're required to show the code properly.
Apr 21 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.