Can someone help me out with this?
I have a database to track Artwork. The artwork filenames are named e.g. 714329-00A.zip, 714329-00B.zip where the letter is the revision of said artwork. In the revision table I have the following fields:
RevisionID, ArtworkID, Revision, RevisionStatus_ID, Path
I have a Continous form that conatains listbox that performs a search of the network for all files based on users input e.g. D:\Artwork\Approved\714329-00A.zip, or D:\Artwork\Pending\714329-00B.zip.
Also on the form I have a control button that when I click on it I want it to lookup the values in a MultiSelect listbox (i.e. 714329-00A.zip, etc.) and search for matching fields in the ArtworkID field of the table/form. If a match is found I want to update the RevisionStatus_ID field of that row.
Below is the Code I have so far. The troubl I'm having is that it is updating all the rows in the table and not those selected in the listbox only.
Thanks for taking a look at this for me.
the Code:
Private Sub SetStatus_Click()
Dim rst As DAO.Recordset
Dim dbs As Database
Dim strLookup As String
Dim ctlSource As Control
Dim intCurrentRow As Integer
Dim strSql As String
Set dbs = CurrentDb
Set rst = CurrentDb.OpenRecordset("Revision", dbOpenDynaset)
Set ctlSource = Me.lstResults
strSql = "Update Revision Set [RevisionStatus_ID] = '" & 1 & "' Where 'ArtworkID.Column(1)' = " & strLookup
For intCurrentRow = 0 To ctlSource.ListCount - 1
If ctlSource.Selected(intCurrentRow) Then
strLookup = strLookup & Left(ctlSource.Column(0, intCurrentRow), 9) & " Or "
End If
Next intCurrentRow
strSql = strSql & strLookup
strSql = Left(strSql, Len(strSql) - 3)
dbs.Execute strSql
Me.Requery
End Sub
I have a database to track Artwork. The artwork filenames are named e.g. 714329-00A.zip, 714329-00B.zip where the letter is the revision of said artwork. In the revision table I have the following fields:
RevisionID, ArtworkID, Revision, RevisionStatus_ID, Path
I have a Continous form that conatains listbox that performs a search of the network for all files based on users input e.g. D:\Artwork\Approved\714329-00A.zip, or D:\Artwork\Pending\714329-00B.zip.
Also on the form I have a control button that when I click on it I want it to lookup the values in a MultiSelect listbox (i.e. 714329-00A.zip, etc.) and search for matching fields in the ArtworkID field of the table/form. If a match is found I want to update the RevisionStatus_ID field of that row.
Below is the Code I have so far. The troubl I'm having is that it is updating all the rows in the table and not those selected in the listbox only.
Thanks for taking a look at this for me.
the Code:
Private Sub SetStatus_Click()
Dim rst As DAO.Recordset
Dim dbs As Database
Dim strLookup As String
Dim ctlSource As Control
Dim intCurrentRow As Integer
Dim strSql As String
Set dbs = CurrentDb
Set rst = CurrentDb.OpenRecordset("Revision", dbOpenDynaset)
Set ctlSource = Me.lstResults
strSql = "Update Revision Set [RevisionStatus_ID] = '" & 1 & "' Where 'ArtworkID.Column(1)' = " & strLookup
For intCurrentRow = 0 To ctlSource.ListCount - 1
If ctlSource.Selected(intCurrentRow) Then
strLookup = strLookup & Left(ctlSource.Column(0, intCurrentRow), 9) & " Or "
End If
Next intCurrentRow
strSql = strSql & strLookup
strSql = Left(strSql, Len(strSql) - 3)
dbs.Execute strSql
Me.Requery
End Sub