Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

listbox problem

Status
Not open for further replies.

sabavno

Programmer
Jul 25, 2002
381
CA
hi

I've got the following problem when I use 'find' routine to locate a row in the list box.

My find routine is:

Dim intRow As Integer
Dim cntl As Control
Dim rst As DAO.Recordset
Dim sql As String
Dim intA As String


intA = InputBox("Enter PIN")

Set cntl = Me!List0
sql = "Select PIN From BlackBerryRecord Where PIN = " & intA & ""

Set rst = CurrentDb.OpenRecordset(sql, dbOpenDynaset)
If rst.NoMatch = False Then
rst.MoveFirst
For intRow = 0 To cntl.ListCount - 1
If List0.Column(1, intRow) = intA Then
List0.Selected(intRow) = True
Exit For
End If
Next intRow
End If

Set rst = Nothing

It works fine, the row gets selected...but then when user clicks on the button "VIEW" or "EDIT" to open the form for the selected record, I get an error message, because form only opens when the row is clicked, not just selected. So, I don't know what to do. Basically I have to force the user after the found row is selected to click on this row...that seems inappropriate.

Please ,if anyone has encountered this problem before. Let me know how could I resolve. How could I make my row be not only selected but clicked automatically?

Thanks
 
Well

I can't do List0.selected(intRow).setfocus it's not optional
How else would I setfocus on the row?
 
Maby I misunderstand but basically what you want to do is have the user make a selection and from this userselection the user should then open a form via the subform? if this is so whey not open the form yourself iso letteing the user do this?
 
Hi!

What does the rest of your code look like? What code opens the form and where is it located? What code do you have behind the view and edit buttons?

After seeing that I am sure we can help.

Jeff Bridgham
bridgham@purdue.edu
 
ok, basically user can click on the row in the text box and then click on the button "View Record" and another form will open based on the value that in the row selected.
This works fine

But when the user does not select row, but clicks directly on the "FIND" button....then the row gets selected, but "View Record" button then wouldn't work
 
here is the code for the "Edit Record" button
Dim stDocName As String
Dim stLinkCriteria As String
Dim intColumn As Integer



stDocName = "EditRecordForm"

stLinkCriteria = "[RecordID]= " & Me![List0]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Listbox is generated on the query and have nothing in the form_load, form_open
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top