473,804 Members | 2,141 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

List Box Set Focus Problem in MS Access 2003

I have a function that will search through a list box and select a
variable. I can get the item in the list box to select, but I cannot
get the list box to go to the selected item. So if the user identifies
a variable at the bottom of the list, the list box may not show it.
Works in Access2000. THIS SEEMS LIKE THIS WOULD BE A SIMPLE PROBLEM TO
FIX.

Nov 13 '05 #1
2 5674
Had the exact same problem. I was typing in a text box, and
having entries in a listbox select or deselect based on what
was typed. In my case, I was allowing multi-select, so you
may not have to do all this.

Private Sub txtSearchPhysic ians_Change()
Dim sEntry As String
Dim sSearch As String
Dim inx As Integer
Dim bFound As Boolean
Dim iSelStart As Integer
Dim iSelLength As Integer

bFound = False
' Create sEntry and search for it
sEntry = UCase(txtSearch Physicians.Text & "")
For inx = 0 To lstPhysicians.L istCount - 1
sSearch = Left(UCase(lstP hysicians.Colum n(2, inx)),
Len(sEntry))

' Embedded spaces are a problem
sSearch = Replace(sSearch , " ", "_")
If sEntry = sSearch And Len(sEntry) > 0 Then
lstPhysicians.S elected(inx) = True
If Not bFound Then
bFound = True
iSelStart = txtSearchPhysic ians.SelStart
iSelLength = txtSearchPhysic ians.SelLength
lstPhysicians.S etFocus
' This is the repositioning magic here. The First
..ListIndex call
' moves the listbox below the desired entry. This
is to show
' the entry in context.
lstPhysicians.L istIndex = Min(inx + 5,
lstPhysicians.L istIndex)
' This next one makes sure you see the entry.
lstPhysicians.L istIndex = inx
txtSearchPhysic ians.SetFocus
txtSearchPhysic ians.SelStart = iSelStart
txtSearchPhysic ians.SelLength = iSelLength
End If
Else
lstPhysicians.S elected(inx) = False
End If
Next

End Sub

colleen<co***** *********@rl.go v> 4/27/2005 2:16:51 PM
I have a function that will search through a list box and
select a
variable. I can get the item in the list box to select,

butI cannot
get the list box to go to the selected item. So if the useridentifies
a variable at the bottom of the list, the list box may not
show it.
Works in Access2000. THIS SEEMS LIKE THIS WOULD BE A
SIMPLE PROBLEM TO
FIX.

Nov 13 '05 #2
Thanks Kevin! It was actually this pesky line:

ctl.ListIndex = i

You have made my users very happy!

Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
85630
by: William Case | last post by:
Hi folks, Screen.PreviousControl.SetFocus works fine to select the control that had focus prior to the one that NOW has focus. Unfortunately, I've not discovered a VBA code way to get the name of the control, that currently has focus. It would be nice if the Screen object had a property called "CurrentControl" that could be stored in a variable, as in: "X = Screen.CurrentControl.Name" Am I overlooking something?
1
3458
by: Dec | last post by:
Ok to simplify things I'll just give an example. This is pretty much what I want to do (minus the postcode): http://www.perrys.co.uk/usedcar?ID=F5J9BNNBMVK00DF I have relatively little experience with databases (hate being a n00b) but I'm currently attempting to put myself through some sort of crash course.. How far have I got? Ok so using MS access 2003. I have a table (table1) with data with a
1
2501
by: Jan Nordgreen | last post by:
I use Access 2003 and WinXP. When my form has Allowedits = false I can not choose a row in the list box that shows some of the fields in the form's record source table. Why not? What is the easiest way around this? I could set Allowedits to true when the list gets focus and back to its original value when it loses focus, but that seems a bit too much. I am using the list box and a simple way to search for records in the
2
2076
by: S P Arif Sahari Wibowo | last post by:
Hi! Do you know how to put a form's Access-Visual-Basic-code that will force the form to be inserted, while the user has not type anything in the form, without changing focus, selection, etc.? Here is the story. I have this structure:
1
2154
by: Gil | last post by:
hello, im automating mappoint through access to get mileage between two address fields. when ever i call the function it makes mappoint the focus, and i have to reclick the access screen to regain access forms focus. how can i get access focus via vba and without having to click the form? i tried using docmd.selectobject acform, "myform" and me.setfocus . it looks like it works by highlighting a text box however the mappoint is still...
3
3515
by: rhobson2 | last post by:
Hello, I wrote a database applicaiton using Access XP (2002) and everything has been working good for the client until they purchased a couple of new computers with Access 2003. The meetings form has an unbound combo box listing all the meetings in the database allowing the user to navigate between meeting records. The meetings form also has a list box that displays a list of members associated with a meeting.
0
1921
by: jvitti | last post by:
I recently upgraded from Access 2000 to Access 2007 and I am having trouble with moving the focus from 1 form to another. While doing data entry if a similar claim is found the claim view form will open listing the similar claims. The data entry clerk can view 1 of the claims and by doubling clicking on the claim number some info from the claim view will be used to populate fields on the data entry screen. The following code is used...
16
3558
by: google | last post by:
In a continuous form the following code is under a button in the form header. In Access 2003 and earlier, this goes to a new record, then adds relevant data to that new record. DoCmd.GoToRecord , , A_NEWREC If <some codeThen = "CA002" Else
1
3829
by: MerlinS | last post by:
Using Access 2003. I have a form and a subform. On the main form, one of the fields is a lost box, which lists line numbers ie 1, 2, 3 etc. Then the list box is clicked, the subform corresponding to the line number info is shown. When a new record is added to the subform the new line number is added and is shown in the main form list box. The list box on the main form gets the focus and the new line number is highlighted. However the new...
0
9594
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10600
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10350
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10351
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10096
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9174
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5534
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5673
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4311
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.