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

Form search criteria

P: 27
Hi ,

I am trying to create an access form with a search on the group name and all the related group IDs on this particular group name must be displayed in the combo box on the form . The group name is same but the group numbers are unique..

Group name: Group Number:

Carribou Coffee 12345
Carribou Coffee 63726
Carribou Coffee 19827

So when i search for Carribou Coffee ....It needs to show me all the related numbers in the list.....

This is the query i wrote for search button....Right now with this it only displays one value.....I want all values.....

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Dim Db As Database
  3. Dim RsGrpName As DAO.Recordset
  4.  
  5. Private Sub cmdGroupNameSearch_Click()
  6. Set RsGrpName = Db.OpenRecordset("SELECT DISTINCT Grp_Number,Grp_Name FROM EmployerGroup Where Grp_Name Like'" & Trim(txtGroupName) & "'")
  7.  
  8. If RsGrpName.RecordCount > 0 Then
  9.  
  10. cboGroupNumbers = RsGrpName.Fields("Grp_Number")
  11. Else
  12. MsgBox "Data Not Available...", vbQuestion
  13. End If
  14.  
  15. End Sub
  16.  
  17. Private Sub form_load()
  18. Set Db = CurrentDb()
  19.  
  20. End Sub
  21.  


waiting for a help from some one....
Thanks,
Jason...
Oct 18 '07 #1
Share this Question
Share on Google+
6 Replies


Rabbit
Expert Mod 10K+
P: 12,315
It should be:
Expand|Select|Wrap|Line Numbers
  1. cboGroupNumbers.RowSource = "SELECT DISTINCT Grp_Number FROM EmployerGroup WHERE Grp_Name Like '" & Trim(txtGroupName) & "';"
  2.  
Oct 18 '07 #2

P: 27
It should be:
Expand|Select|Wrap|Line Numbers
  1. cboGroupNumbers.RowSource = "SELECT DISTINCT Grp_Number FROM EmployerGroup WHEREGrp_Name Like '" & Trim(txtGroupName) & "';"
  2.  
Hi,

Thanks for the solution that worked for me.....

I have another question in the same GroupName field now i have to type the whole name and then i say search so that it will get the group numbers....

But is there any way that i start typing and it will display all the related names that start with those letters and allow me to pick from them.. so that my intension is that if the user miss spells one word there wont be much difference as we give him the list of all names....Is that possible....

Please help me with the code changes...
As iam learning VB and using for the first time...I dont know much tricks in it....

Thanks for ur help.....
Will be waiting to hear something......
Jason...
Oct 18 '07 #3

NeoPa
Expert Mod 15k+
P: 31,186
Check out Example Filtering on a Form for a full rundown, but Rabbit's right in that he highlighted the fundamentals of where your code goes wrong.
You don't do it with a recordset. You set the RecordSource to the SQL you want.
Oct 18 '07 #4

NeoPa
Expert Mod 15k+
P: 31,186
...
But is there any way that i start typing and it will display all the related names that start with those letters and allow me to pick from them.. so that my intension is that if the user miss spells one word there wont be much difference as we give him the list of all names....Is that possible....
Check out the AutoExpand property of the ComboBox control.
Oct 18 '07 #5

P: 27
Need Help with combo box display
--------------------------------------------------------------------------------

Hi,

I have a form and i have a combo box that gets loaded with the last name and first name being concatenated at the time of loading into the combobox and i select from that list ...

So the problem is if i select any name then it is breaking up and moving into a second line in the combobox..

Example:

Jason Meyers ----- I select this


Result

Jason
Meyers ---- I dont want it to be like that


I want it to be in the same line as it was displayed and need to remain like that after selection.....


Desired Result:

Jason Meyers




Waiting for help

Thanks
Jason.
Oct 27 '07 #6

NeoPa
Expert Mod 15k+
P: 31,186
Jason,

Some of this is clear :)
What is not clear is where this name is displaying wrongly. Is it in the ComboBox itself (after selection)? Or is the value used elsewhere?
Something that would be helpful too is the source settings of the ComboBox. Does it use a query (if so post in the SQL)? Is it a value list (If so post in the value list)?
Oct 27 '07 #7

Post your reply

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