By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,965 Members | 2,043 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,965 IT Pros & Developers. It's quick & easy.

[VB6] combo to search change - can't figure it out

P: n/a
for your info - I'm a newbe.
Code is at the bottom.
Access dbase (each form ca. 10 KB) if my explanations are not enough
(probably they aren't).

-- access 97 - http://www.lokalny.net/Source97.zip
-- access 200 - http://www.lokalny.net/Source2000.zip

------
Im trying to change code - just trying to learn something. But nothing seems
to work.
Advice, hint ... anything would be helpfull.

Current situation:
-- after picking an option from a combo box (cboList), that option is being
shown in list box (lstInfo)
-- after clicking that new entry in (lstInfo) data is being distributed to
several text boxes.

What I'm trying to accomplish:
-- comboBox (cboList) - gone,
-- txtBox instead for entering a string and searching (say) xType column in
database
-- search results displayed in list box (lstInfo)
-- upon click on any of these results in list box (lstInfo) data from
recordset should be distributed to text boxes as it is now.

--------------
Here is code:
--------------
Option Explicit

Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset

Private Sub cboList_Click(Index As Integer)
Dim t_Records As Long, t_Counter As Long
txtInfo(0).Text = ""
txtInfo(1).Text = ""
txtInfo(2).Text = ""
lblData(0).Caption = ""
'lblData(1).Caption = ""
lblData(2).Caption = ""
lstInfo.Clear
Label3.Visible = True
With rs

.Open "SELECT ID, xType, xSubType, SearchNote From tblSource Where
tblSource.xType = '" & cboList(0).Text & "' ORDER BY xSubType;"
If Not .EOF Then
lstInfo.Clear
t_Records = .RecordCount
For t_Counter = 1 To t_Records

lstInfo.AddItem .Collect(2) & " (" & Left(.Collect(3),
100) & ") ........"
lstInfo.ItemData(lstInfo.NewIndex) = .Collect(0)
.MoveNext
Next t_Counter
End If
If .State = adStateOpen Then .Close
End With
End Sub

Private Sub Command1_Click()
Unload Me
End Sub

Private Sub Form_Load()
On Error GoTo errH

Dim strPath As String
strPath = App.Path & "\Source.mdb"
With cn
.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strPath &
";Persist Security Info=False"
End With

With rs
.ActiveConnection = cn
.CursorType = adOpenKeyset
.LockType = adLockOptimistic
End With
With tmData
.Interval = 123
.Enabled = True
End With
Exit Sub
errH:
If Err.Number = -2147467259 Then
MsgBox "Data file not found, ensure that the data file is in the " &
strPath & " directory " & vbCrLf & "This form will unload now", vbCritical,
"NBS Solutions"
Unload Me
Exit Sub
Else
Resume Next
End If
End Sub
Private Sub loadCAT()
With rs
.Open "SELECT DISTINCT xType From tblSource ORDER BY
xType;"
If Not .EOF Then
cboList(0).Clear
Do While Not .EOF
cboList(0).AddItem .Collect(0)
.MoveNext
Loop
End If
If .State = adStateOpen Then .Close
End With
End Sub
Private Sub loadInfo()
With rs
.Open "SELECT ID, xType, xSubType, xCode, xDeclarations,
xDescription, xNote, xRefrences FROM tblSource" _
& " WHERE ID =" & lstInfo.ItemData(lstInfo.ListIndex) & ""

If Not .EOF Then
txtInfo(0).Text = .Collect(4)
txtInfo(1).Text = .Collect(3)
txtInfo(2).Text = .Collect(6)
lblData(0).Caption = .Collect(5)
lblData(2).Caption = .Collect(7)
End If
If .State = adStateOpen Then .Close
End With
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
On Error Resume Next
rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing
End Sub
Private Sub lstInfo_Click()
loadInfo
End Sub

Private Sub tmData_Timer()
tmData.Enabled = False
tmData.Interval = 0
loadCAT
End Sub



Nov 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
"Jeff" <ze****@opYAKNOWWHATTODO.pl>'s wild thoughts were
released on Wed, 29 Dec 2004 22:06:27 +0100 bearing the
following fruit:
for your info - I'm a newbe. Code is at the bottom.
Access dbase (each form ca. 10 KB) if my explanations are not enough
(probably they aren't).

-- access 97 - http://www.lokalny.net/Source97.zip
-- access 200 - http://www.lokalny.net/Source2000.zip

------
Im trying to change code - just trying to learn something. But nothing seems
to work.
Advice, hint ... anything would be helpfull.

<SNIP>

People tend to avoid answering questions that have been
crossposted to too many groups and even more so when it has
been posted to group(s) in which the question is off topic.

Jan Hyde (VB MVP)

--
Incest is relatively boring. Necrophillia is dead boring. (Hugh Janus)

[Abolish the TV License - http://www.tvlicensing.biz/]

Nov 21 '05 #2

P: n/a
thank You for a hint.
This is a first time I use usenet also :)
So no hard feelings ppl
Don't cuss to hard.
Peace ...
"Jan Hyde" <St***********@REMOVE.ME.uboot.com> wrote in message
news:0p********************************@4ax.com...
"Jeff" <ze****@opYAKNOWWHATTODO.pl>'s wild thoughts were
released on Wed, 29 Dec 2004 22:06:27 +0100 bearing the
following fruit:
for your info - I'm a newbe.

Code is at the bottom.
Access dbase (each form ca. 10 KB) if my explanations are not enough
(probably they aren't).

-- access 97 - http://www.lokalny.net/Source97.zip
-- access 200 - http://www.lokalny.net/Source2000.zip

------
Im trying to change code - just trying to learn something. But nothing seemsto work.
Advice, hint ... anything would be helpfull.

<SNIP>

People tend to avoid answering questions that have been
crossposted to too many groups and even more so when it has
been posted to group(s) in which the question is off topic.

Jan Hyde (VB MVP)

--
Incest is relatively boring. Necrophillia is dead boring. (Hugh Janus)

[Abolish the TV License - http://www.tvlicensing.biz/]

Nov 21 '05 #3

P: n/a
"Jeff" <ze****@opYAKNOWWHATTODO.pl>'s wild thoughts were
released on Thu, 30 Dec 2004 21:43:13 +0100 bearing the
following fruit:
thank You for a hint.
This is a first time I use usenet also :)
So no hard feelings ppl
Don't cuss to hard.
Peace ...
Now, first decide if this is a VB question or a VB.Net
question. Then crosspost to no more than 2 or 3 relevant
groups.

However for VB question I would suggest just posting to

microsoft.public.vb.general.discussion

And for VB.Net questions

microsoft.public.dotnet.languages.vb

And that is usally enough. If no-one knows the answer they
can direct you to a better group to ask your question in.

"Jan Hyde" <St***********@REMOVE.ME.uboot.com> wrote in message
news:0p********************************@4ax.com.. .
"Jeff" <ze****@opYAKNOWWHATTODO.pl>'s wild thoughts were
released on Wed, 29 Dec 2004 22:06:27 +0100 bearing the
following fruit:
>for your info - I'm a newbe.

>Code is at the bottom.
>Access dbase (each form ca. 10 KB) if my explanations are not enough
>(probably they aren't).
>
>-- access 97 - http://www.lokalny.net/Source97.zip
>-- access 200 - http://www.lokalny.net/Source2000.zip
>
>------
>Im trying to change code - just trying to learn something. But nothingseems >to work.
>Advice, hint ... anything would be helpfull.

<SNIP>

People tend to avoid answering questions that have been
crossposted to too many groups and even more so when it has
been posted to group(s) in which the question is off topic.

Jan Hyde (VB MVP)

--
Incest is relatively boring. Necrophillia is dead boring. (Hugh Janus)

[Abolish the TV License - http://www.tvlicensing.biz/]

Jan Hyde (VB MVP)

--
So I met this gangster who pulls up the back of people's pants, it
was Weggie Kray.

[Abolish the TV License - http://www.tvlicensing.biz/]

Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.