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

Search function help

100+
P: 111
Hey guys,

I have a form that is used solely as a search page. It allows the user to enter either a GroupName or GroupNumber in 2 different text boxes with a button under each one. the OnClick property of the buttons is coded to match either the GroupName or GroupNumber and open a new form with the appropriate data. The search function itself works fine, but my problem is that whenever someone searches for a name or number, it is storing those values in the table. Is it possible to not store these values? Is my design all wrong?
Aug 14 '07 #1
Share this Question
Share on Google+
10 Replies


JKing
Expert 100+
P: 1,206
Could you post the code for the Onclick events? This would help us in narrowing down the problem. Thanks.
Aug 14 '07 #2

100+
P: 111
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command47_Click()
  2. On Error GoTo Err_Command47_Click
  3.  
  4.     Dim stDocName As String
  5.     Dim stLinkCriteria As String
  6.  
  7.     stDocName = "frmMainGroup"
  8.     DoCmd.RunCommand acCmdWindowHide
  9.     stLinkCriteria = "[GroupNumber]=" & "'" & Me![GroupNumber] & "'"
  10.     DoCmd.OpenForm stDocName, , , stLinkCriteria
  11.  
  12. Exit_Command47_Click:
  13.     Exit Sub
  14.  
  15. Err_Command47_Click:
  16.     MsgBox Err.Description
  17.     Resume Exit_Command47_Click
  18.  
  19. End Sub
  20.  
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command48_Click()
  2. On Error GoTo Err_Command48_Click
  3.  
  4.     Dim stDocName As String
  5.     Dim stLinkCriteria As String
  6.  
  7.     stDocName = "frmMainGroup"
  8.     DoCmd.RunCommand acCmdWindowHide
  9.     stLinkCriteria = "[GroupName]=" & "'" & Me![GroupName] & "'"
  10.     DoCmd.OpenForm stDocName, , , stLinkCriteria
  11.  
  12. Exit_Command48_Click:
  13.     Exit Sub
  14.  
  15. Err_Command48_Click:
  16.     MsgBox Err.Description
  17.     Resume Exit_Command48_Click
  18.  
  19. End Sub
  20.  
Aug 14 '07 #3

100+
P: 111
the problem isnt really with the search function itself, i think its more do with how i have the form set up. the search form has the same RecordSource as the form that i'm opening, which is where its storing these values.
Aug 14 '07 #4

JKing
Expert 100+
P: 1,206
The search form shouldn't be bound and neither should the combo boxes on the search form.

What you want to do is have two unbound combo boxes that through a query look up the values you want rather than having them as bound controls.
Aug 14 '07 #5

100+
P: 111
is it possible to do this without using a combo box? Or have the combo box be data entry only? I dont want the user to have the Drop down capabitlites and be able to see all the different names in the list.
Aug 14 '07 #6

JKing
Expert 100+
P: 1,206
You can do the same thing with textboxes. The way you have your code setup I believe if you just remove the record source from the search form and the control sources of the textboxes, it should work fine.
Aug 14 '07 #7

100+
P: 111
that worked great! such an easy fix!

Now im having the problem of whenever the user opens the search page, the last thing that was searched for is still in the text box. Its unbound so i'm not sure why this is sticking! Any thoughts?
Aug 14 '07 #8

JKing
Expert 100+
P: 1,206
If they aren't bound this shouldn't be happening. Are you infact closing the search form or just hiding it? Are you setting the default value of the textboxes?
Aug 14 '07 #9

100+
P: 111
Expand|Select|Wrap|Line Numbers
  1. DoCmd.RunCommand acCmdWindowHide
this is my code....so i am in fact just hiding it. Is that the problem? If so, how can i auto close the window?
Aug 14 '07 #10

JKing
Expert 100+
P: 1,206
You could use Docmd.close to close the search form.

Or if you prefer you could also just clear the textboxes when the user clicks one of the buttons.
Aug 14 '07 #11

Post your reply

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