Grabbing values from Search List Box (1 Viewer)

SkyCraw

Registered User.
Local time
Today, 03:39
Joined
Oct 9, 2013
Messages
100
Good morning everyone,

Thanks (many thanks) to John Big Booty's post below, I was able to create a very user-friendly pop-up search form:

http://www.access-programmers.co.uk/forums/showthread.php?t=188663

I would like to take it a step further... Now, I would like to grab the selected record ID from within one of the list box columns and use it in my SQL statement (to copy the record into a new one). Is there any way to reference a highlighted record value within a list box recordset directly and/or any workarounds?

I know one would be to grab the ID and insert it into the text box, just don't know what the coding references would be for this.

Many thanks! :)
 

GinaWhipp

AWF VIP
Local time
Today, 02:39
Joined
Jun 21, 2011
Messages
5,899
Since your code will only grab the selected iD no speial code is needed UNLESS you are using milti-select list box. You can grap the same way you grab any controls value... have you done that before?
 

Rx_

Nothing In Moderation
Local time
Today, 00:39
Joined
Oct 22, 2009
Messages
2,803
Dim CurrentlstWells_Selected As Integer
CurrentlstWells_Selected = Me!lst_id_wells
' then use this in a select statement "Select * from Wells where Well_ID = " & CurrentlstWells_Selected

or another example
strSQL = "SELECT * FROM qlstWellsHome2 WHERE State = '" & cboState.Column(2) & "';"
 

SkyCraw

Registered User.
Local time
Today, 03:39
Joined
Oct 9, 2013
Messages
100
Ah, that is how you do that... I was originally going to do it that way but somehow I overlooked doing it that way while doing some trial-and-error.

Thanks GinaWhipp!
 

GinaWhipp

AWF VIP
Local time
Today, 02:39
Joined
Jun 21, 2011
Messages
5,899
No problem... and thanks Rx for posting some examples!
 

Users who are viewing this thread

Top Bottom