473,407 Members | 2,326 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,407 software developers and data experts.

How to select a record from a list box

Hi,

I hope someone can help me. I have a form where I add data. I also have a search button on there that opens another form (listbox) showing all the records. If I want to edit a record, I want to be able to double click on a specific record in the listbox, and then bring me back to the main form and go to the record i just chose in the list box.

Please help!!!!!

Thanking you in advance,

Ryno
Nov 18 '10 #1
4 2024
Steven Kogan
107 Expert 100+
There is a peculiarity with the double-click event where the focus returns to the original form when you open another form. To solve that, set cancel= true.

This sort of code would work:

Expand|Select|Wrap|Line Numbers
  1. Private Sub List0_DblClick(Cancel As Integer)
  2.     Cancel = True
  3.     DoCmd.Close acForm, "Form1"
  4.     DoCmd.OpenForm "Form1", acNormal, , "[ID]=" & Me.List0
  5. End Sub
  6.  
Nov 18 '10 #2
Hi Steven,

I tried your code, but it brings me back to the form to add a new record, it does not choose the record I chose from the listbox. Any other suggestions?
Nov 18 '10 #3
colintis
255 100+
Ryno,

Please take notice the example code, it closes Form1 and then open Form1 again. This is actually an example for your reference, not an exact answer to your question. Try work around with and see if it works, you might also need to find a way to accept the parameter in the second form.
Nov 19 '10 #4
Steven Kogan
107 Expert 100+
The last parameter, "[ID]=" & Me.List0, is the where clause. For this to work ID would be your key field, and the first column in your list box would be the key field. It should filter the records matching the criteria, which may not be what you want to do. If you close the form first it should clear any pre-existing filters.

More generally you would need a way to identify the record, preferably uniquely but not necessarily.

Can you provide specifics such as the form name, field name, and how you would identify the record to be selected?

Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenForm "Form1", acNormal, , "[ID]=" & Me.List0 
  2.  
Nov 19 '10 #5

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

Similar topics

4
by: Eric Freeman | last post by:
Is there any way in Postgres to SELECT a list of table names from inside of a C program using ECPG? Something similar to SELECT current_user that will give you all of the tables in the database...
4
by: VK | last post by:
I'm looking for autoexpand <select> list onfocus and collapse it back onselect/onblur (the list is select-one type) I know it is not possible directly, but I've seen here a hack by changing...
6
by: AA Arens | last post by:
Hi, I have a database with 2 main forms. Contacts and companies. I share the base with two others via LAN. On the companies form I have buttons to navigate throught the records (>400). We are...
3
by: Beholder | last post by:
I hope that someone can help me with the following: Short background explenation: I have a shrfepoint page (newform.aspx) in a item list. On this page is a lookup column that displays a lookup...
5
by: =?Utf-8?B?bWNhdWxpZmZl?= | last post by:
I have an old application ( pre-VB5) that I need to add a select/option list to. This is an edit program so the values for the form will be retrieved from a database. How do I set the value of...
3
by: reverendjb | last post by:
I'm stumped on this one, so here goes.... I have 2 tables project and assignment they are linked by the field proj_id where proj_id is the primary key of project and a foreign key in...
2
by: Shivajirp | last post by:
I have table in which Shift no, Start time. End time. if start time of shift is 6pm and end time of shift is 6 am then I want to select record between start time and end time.I need query to selct...
0
by: Andrus | last post by:
How to create select columns list dynamically in DLinq ? I want to create something like Console.WriteLine("Enter list of columns to return, separated by commas:"); string list =...
1
by: rk2008 | last post by:
Hi, I'm using following code to select a record on a form from dropdown list and I'm using MSSQL ODBC linked tables inside MS Access: Private Sub cboFind_AfterUpdate() Dim strCriteria As String...
8
by: simonc88 | last post by:
Hi guys hope you can help with this one, I have a list box being fed by a table, the list box has 3 columns with the first being an ID number and displays the records that are saved in the table....
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
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
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.