|
-
Jun 16th, 2004, 03:57 AM
#1
Thread Starter
Addicted Member
Listbox Database
Hi
Firstly I have a listbox and I want the user to select an item from the list box and then click cmdStartStop
when cmdStartStop is pressed i want it to put "Not Running" into the field Live WHERE the Campaign_Name is = to the lstnotrunning.text
I am trying to put the variable Not Running Select into the **Insert NotRunningSelect** but it doesn't alow me to
VB Code:
Dim NotRunningSelect As String
NotRunningSelect = lstNotRunning.Text
If cmdStartStop.Caption = "Stop Campaign" Then
NotRunning.Source "Select * From T_Campaigns WHERE Campaign_Name = **Insert NotRunningSelect** "
NotRunning.Open , db, adOpenKeyset, adLockOptimistic
NotRunning.Fields(Live).Value = "Not Running"
Any idea on what im doin wrong or a better way to do it
tnx adz
Last edited by k0r54; Jun 16th, 2004 at 04:14 AM.
-
Jun 16th, 2004, 04:24 AM
#2
Thread Starter
Addicted Member
it has to be something simple
-
Jun 16th, 2004, 04:27 AM
#3
you have to do something like
VB Code:
recordset.add
("Field") = "not running"
recordset.update
-
Jun 16th, 2004, 04:29 AM
#4
Re: Listbox Database
What is NotRunning? Is it an ADODB.Recordset?
Try this.
VB Code:
Dim NotRunningSelect As String
NotRunningSelect = lstNotRunning.Text
If cmdStartStop.Caption = "Stop Campaign" Then 'Why are you doing this?
NotRunning.Source "Select * From T_Campaigns WHERE Campaign_Name = '" & NotRunningSelect & "';"
NotRunning.Open , db, adOpenKeyset, adLockOptimistic
NotRunning.Fields(Live).Value = "Not Running"
NotRunning.Update
-
Jun 16th, 2004, 04:39 AM
#5
Thread Starter
Addicted Member
yes it is a adodb connection
I am now getting an error of
Runtime Error '3021'
either bof or eof is tru and the current record hs been deleted requested operation requires a current record
The record does exist i know it does.
it is stopping at .feilds....
i am now using the code
VB Code:
Dim NotRunningSelect As String
NotRunningSelect = lstNotRunning.Text
If cmdStartStop.Caption = "Stop Campaign" Then
NotRunning.Source = "Select * From T_Campaigns WHERE Campaign_Name = '" & NotRunningSelect & "';"
NotRunning.Open , db, adOpenKeyset, adLockOptimistic
With NotRunning
.Fields("Live").Value = "Not Running"
.Update
End With
End If
tnx adz
-
Jun 16th, 2004, 04:53 AM
#6
Do a msgbox of
objrs.bof
objrs.eof
objrs.recordcount
See what you get.
-
Jun 16th, 2004, 05:03 AM
#7
Thread Starter
Addicted Member
sorry but how do i do that :S, i cant remember
-
Jun 16th, 2004, 05:21 AM
#8
MsgBox objrs.BOF
Simple, isn't it?
Do this after you've opened up the recordset.
-
Jun 16th, 2004, 05:33 AM
#9
Thread Starter
Addicted Member
sorry yeah i was putting them all on 1 line lol
ok bof and eof are true
and recordcount is 0
-
Jun 16th, 2004, 05:34 AM
#10
Use lstNotRunning.List(lstNotRunning.ListIndex) directly, storing to a string is just additional code for a short implementation. Make the list style dropdown list. Make sure there are no special formatting (eg, vbTab, vbCrLf, etc) in the record string, you would never get a match with the list item otherwise.
-
Jun 16th, 2004, 06:01 AM
#11
Thread Starter
Addicted Member
firstly it can't be a drop down.
i have taken out the variable, and now im a bit confused coz do i use lstnotrunning.text or lstnotrunning.list(lstnotrunning.listindex) to tell it what campaign is currently selected.
But with both i still get the same error,
also as a Q recordcount is at 0 does this mean there are no records at all, or no records matchin the selected item.
Thanks Adam
-
Jun 16th, 2004, 06:48 AM
#12
Thread Starter
Addicted Member
??
-
Jun 16th, 2004, 06:54 AM
#13
It means that there is nothing to match. You need to check the values... there will probably be a slight difference between what's on the form, and what's in the db.
-
Jun 16th, 2004, 09:07 AM
#14
Thread Starter
Addicted Member
ok i found the problem
it is at this point
VB Code:
WHERE Campaign_Name = ' " & lstNotRunning.List(lstNotRunning.ListIndex) & " ' ;"
its not finding the selected item i have also tried lstnotrunning.text coz im not sure which on to use.
Last edited by k0r54; Jun 16th, 2004 at 09:25 AM.
-
Jun 16th, 2004, 10:36 AM
#15
Thread Starter
Addicted Member
?? i have still had no luck
-
Jun 16th, 2004, 10:39 AM
#16
What sort of content does the listbox (and the db table) hold?
-
Jun 16th, 2004, 11:57 AM
#17
Thread Starter
Addicted Member
words
the table has 5 columns
Campaign_Name = text
Start_Date=date but is a text field
Manager = text
Assistant = text
Live = text
the listbox is pulling the data from from this table so i know the spelling is corrent and everything
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|