473,406 Members | 2,371 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Dropdown A, B, C... to jump to names

7
Hello,

I am using Access 2002. I created a database where names are stored.
Now I want to add a drop down menu which contains the alphabet, means A, B, C... Y, Z. By selecting H for example, the form should jump to the first name in the database starting with H.
I tried the following code but there was no effect on the form. Nothing happened.
[fullname] is a field in the database as well as in the form.

Thank you for helping.

Tobias

Expand|Select|Wrap|Line Numbers
  1. Private Sub gotoselect_Change()
  2.  
  3.     Dim strCriteria As String
  4.  
  5.     Dim rst As DAO.Recordset
  6.  
  7.     Set rst = Me.RecordsetClone
  8.  
  9.     strCriteria = "[fullname] = '" & Me![gotoselect] & "'"
  10.  
  11.     rst.FindFirst strCriteria
  12.  
  13.     Me.Bookmark = rst.Bookmark
  14.  
  15. End Sub
  16.  
  17.  
Jul 2 '07 #1
12 1673
missinglinq
3,532 Expert 2GB
I'm confused! A standard combobox, with AutoExpand set to Yes (the default) will take you to the first name beginning with a H.

Hitting <Enter> will then retrieve that record, and you'll be in the H's!
Jul 2 '07 #2
puppydogbuddy
1,923 Expert 1GB
Hello,

I am using Access 2002. I created a database where names are stored.
Now I want to add a drop down menu which contains the alphabet, means A, B, C... Y, Z. By selecting H for example, the form should jump to the first name in the database starting with H.
I tried the following code but there was no effect on the form. Nothing happened.
[fullname] is a field in the database as well as in the form.

Thank you for helping.

Tobias

Expand|Select|Wrap|Line Numbers
  1. Private Sub gotoselect_Change()
  2.  
  3.     Dim strCriteria As String
  4.  
  5.     Dim rst As DAO.Recordset
  6.  
  7.     Set rst = Me.RecordsetClone
  8.  
  9.     strCriteria = "[fullname] = '" & Me![gotoselect] & "'"
  10.  
  11.     rst.FindFirst strCriteria
  12.  
  13.     Me.Bookmark = rst.Bookmark
  14.  
  15. End Sub
  16.  
  17.  
Try this:
Expand|Select|Wrap|Line Numbers
  1. Private Sub gotoselect_AffterUpdate()
  2.  
  3.     Dim strCriteria As String
  4.  
  5.     Dim rst As DAO.Recordset
  6.  
  7.     Set rst = Me.RecordsetClone
  8.  
  9.     strCriteria = "Me![fullname] = '" & Me![gotoselect].Value & "'"
  10.  
  11.     rst.FindFirst strCriteria
  12.  
  13.      If rst.NoMatch Then
  14.         MsgBox "No match was found."
  15.  
  16.      Else
  17.  
  18.         Me.Bookmark = rst.Bookmark
  19.  
  20.      End If
  21.    rst.Close        
  22. End Sub
  23.  
Jul 2 '07 #3
paludi
7
Try this:
Expand|Select|Wrap|Line Numbers
  1. Private Sub gotoselect_AffterUpdate()
  2.  
  3.     Dim strCriteria As String
  4.  
  5.     Dim rst As DAO.Recordset
  6.  
  7.     Set rst = Me.RecordsetClone
  8.  
  9.     strCriteria = "Me![fullname] = '" & Me![gotoselect].Value & "'"
  10.  
  11.     rst.FindFirst strCriteria
  12.  
  13.      If rst.NoMatch Then
  14.         MsgBox "No match was found."
  15.  
  16.      Else
  17.  
  18.         Me.Bookmark = rst.Bookmark
  19.  
  20.      End If
  21.    rst.Close        
  22. End Sub
  23.  

Thank you for your idea.
Unfortunately I get runtime error 3070
because Me![fullname] is not correct, only [fullname]....

Maybe something else makes problems. So probably easier to use a simple text field.
Jul 2 '07 #4
puppydogbuddy
1,923 Expert 1GB
From your original post.
[fullname] is a field in the database as well as in the form.

Try this:
strCriteria = "Me![fullname].Value = '" & Me![gotoselect].Value & "'"
Jul 2 '07 #5
paludi
7
From your original post.
[fullname] is a field in the database as well as in the form.

Try this:
strCriteria = "Me![fullname].Value = '" & Me![gotoselect].Value & "'"

I think the problem is that I show only one record in the form. So Access compares the value of my combo box with the value of that particular value and not with all values in the database.

Now I always get the message "No match found" even if I select e.g. "B" and the shown name is "Binu"...

How can I search the whole DB?

Thanks for your help.
Jul 2 '07 #6
puppydogbuddy
1,923 Expert 1GB
I think the problem is that I show only one record in the form. So Access compares the value of my combo box with the value of that particular value and not with all values in the database.

Now I always get the message "No match found" even if I select e.g. "B" and the shown name is "Binu"...

How can I search the whole DB?

Thanks for your help.
Are you trying to dowildcard finds?
Go back to using change event
Try this:
strCriteria = "[fullname] Like '" & Chr(34) & "*" & Chr(34) & Me![gotoselect].Value & "'"
Jul 2 '07 #7
puppydogbuddy
1,923 Expert 1GB
Are you trying to dowildcard finds?
Go back to using change event
Try this:
strCriteria = "[fullname] Like '" & Chr(34) & "*" & Chr(34) & Me![gotoselect].Value & "'"
oops! wildcard should be at the end of the string.
strCriteria = "[fullname] Like '" & Me![gotoselect].Value & Chr(34) & "*" & Chr(34) & "'"
Jul 2 '07 #8
puppydogbuddy
1,923 Expert 1GB
oops! wildcard should be at the end of the string.
strCriteria = "[fullname] Like '" & Me![gotoselect].Value & Chr(34) & "*" & Chr(34) & "'"
I am not sure about the quotes around the wildcard, so try this way if above doesn't work:

strCriteria = "[fullname] Like '" & Me![gotoselect].Value & Chr(34) & * & Chr(34) & "'"
Jul 2 '07 #9
paludi
7
oops! wildcard should be at the end of the string.
strCriteria = "[fullname] Like '" & Me![gotoselect].Value & Chr(34) & "*" & Chr(34) & "'"
Thank you so much!
This is the correct solution:
Expand|Select|Wrap|Line Numbers
  1. strCriteria = "[fullname] Like '" & Me![gotoselect].Value & "*" & "'"
no need for Chr(34) because then I get double quotes. So for string search I have to use LIKE...
Thanks again!
Jul 2 '07 #10
missinglinq
3,532 Expert 2GB
I have to ask again, why don't you use a standard combobox, with AutoExpand set to Yes? You enter one letter, hit <Enter> and you'll be taken to the first record where the name starts with that letter. You'll then be able to navigate thru all records starting with that letter.
Jul 3 '07 #11
paludi
7
I have to ask again, why don't you use a standard combobox, with AutoExpand set to Yes? You enter one letter, hit <Enter> and you'll be taken to the first record where the name starts with that letter. You'll then be able to navigate thru all records starting with that letter.
standard combobox means a dropdown list, isn't it? that is what I am using. I can select only one letter. The thing is that I find it easier to use only the mouse and not the keyboard in many cases when I only want to look up some data entries.

My problem was the code behind it. For your solution I also need the same code or is there any other way?
Jul 3 '07 #12
I went through the thread quickly, so I might have missed this. If I wanted a dropdown list of first letters of names, I would create a query where all unique first letters from the names field. This way I wouldn't have any letters in the dropdown that don't occur in the data. When a specific letter is selected, I would have my browse criteria.
Jul 3 '07 #13

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

Similar topics

4
by: Marc | last post by:
I've gotten everything up and running except for this -- I'd like to be able to have people have a dropdown list of cities in the US to use (or wherever) and not have to input them manually into a...
20
by: Dannyboyo | last post by:
I have what I hope is a simple request. I can't really code in javascript, but I am pretty good at cusomizing it with slight modifications. I code in ASP and HTML. I am trying to capture customer...
4
by: Sleepless on the Web | last post by:
Is there a limit to how many items can be in a jump list? My script worked fine with 126 items, but at 152 items it just doesn't work. When I select a page from the drop down menu it will only...
3
by: dw | last post by:
Hello. I'm trying to display thousands of people's names so a user can pick one. Is a dropdown the best way to do this? Is there a better way? I've never had to deal with that many names, so I...
2
by: JP SIngh | last post by:
Hi All I just wondering if someone can suggest a solution to this tricky issue we have got. I have an asp form which allow our users to create a new record and save it to the database. On the...
3
by: Developerforum | last post by:
Hi, My customer is looking for a web control that allow them to perform speedy data entry. They wanted a dropdown list box which they can also key in the code directly (like a text box). I...
0
by: poppy | last post by:
I have a dropdown on a webform which lists employee names. When the user sets focus on this combo and enters a letter such as "M" then the displayed values jump to the entries which start with...
11
by: eureka | last post by:
Hi All, I'm training in Servlets, JSP and JavaScript, I have a web page in which there's a "StudentName" textbox and below it is a "Names" Dropdown list. Initially the Textbox is empty and...
4
by: zion4ever | last post by:
Hello good people, Please bear with me as this is my first post and I am relative new to ASP. I do have VB6 experience. I have a form which enables users within our company to do an intranet...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.