Recordsets in listbox for editing

V

Victoria.sv

Dear friends,

Please could anybody possibly help me with my great problem that can
can be a trifle for most of you! Sorry for my question but I spent so
my time trying to solve it !!!!!

So, I have listbox in the form and the source for it - SELECT from the
table.
The only thing I should do - choose not all records, but only some of
them to apply UPDATE SQL query. Now my code makes ALL records in
listbox selected ( I can change the selection manualy after procedure)
and updates ALL. So I suppose it can be two possibilities: 1. to add in
my UPDATE SQL quiry additional WHERE clause - update only records that
are selected, but I can not write that code :(
2. to open recordset in list box for editing ( at least one column),
make this new field check box and include the criteria checkbox = true
in my UPDATE SQL.
BUT I can not edit my recordset in listbox, only can change the
selection!

Please help!

Thanks a lot!
Victoria
My code is following:


Dim sqlstring As String
Dim rs As DAO.Recordset
Dim cnCurrent As ADODB.Connection
Dim ds As DAO.Database
Dim lfilenme As String
Dim ffilenme As String

Public Sub Command6_Click()
Set ds = CurrentDb

Form_InCheck.Command6.Caption = "WAIT!"

SEQrange = Form_InCheck.NumInt.Value
TAPName = Form_InCheck.Text2.Value

If Len(SEQrange) >= 9 Then

ffilenme = "CD" & TAPName & "RUSNW" & Left$(SEQrange, 5)
lfilenme = "CD" & TAPName & "RUSNW" & Right$(SEQrange, 5)

sqlstring = "SELECT TAPIN.FILENAME, TAPIN.XDR, TAPIN.XDRTAX,
[TAPIN].[XDR]+[TAPIN].[XDRTAX] AS XDRtotal, TAPIN.CUR, TAPIN.CURTAX,
[TAPIN].[CUR]+[TAPIN].[CURTAX] AS CURtotal,TAPIN.INVOICED FROM tapin
WHERE (((TAPIN.FILENAME) > '" & ffilenme & "' And (TAPIN.FILENAME)< '"
& lfilenme & "'));"

Set rs = ds.OpenRecordset(sqlstring)
rs.MoveFirst

Form_InCheck.List4.RowSource = sqlstring
Form_InCheck.List4.Requery


Form_InCheck.List4.Selected(2) = True

For i = 1 To Form_InCheck.List4.ListCount
Form_InCheck.List4.Selected(i) = True
Next

End If

End Sub

+++++++++++++++++++++++++++++++++++++++++++++++++++
Public Sub setInvNum_Click()
Dim strSQL As String

Call Command6_Click
Set cnCurrent = CurrentProject.Connection

strSQL = "UPDATE TAPIN SET TAPIN.INVOICED = '" &
[Forms]![InCheck]![invNum].Value & "'" & _
"WHERE (((TAPIN.FILENAME) > '" & ffilenme & "'" & _
"And (TAPIN.FILENAME)< '" & lfilenme & "'))"

cnCurrent.Execute strSQL


End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top