I have a datagrid and want to allow the user to select multiple records. The program will then use the contract numbers of these selected records to build a query to be passed to a report printing only those selected contracts. This is the code I am using to create the query, but it never increments to the next bookmark. It continues to add the same contract number to the query over and over. How do you increment through the selbookmarks?
Dim sQry As String
Dim sFirst As Boolean
Dim varBmk As Variant
sFirst = True
For Each varBmk In DataGrid1.SelBookmarks
If sFirst Then
sQry = ("{JOBCOST.Contn} = '" & DataGrid1.Columns(0) & "'"
sFirst = False
Else
sQry = sQry & " or {JOBCOST.Contn} = '" & DataGrid1.Columns(0) & "'"
End If
DataGrid1.SelBookmarks.Remove (0)
Next
Dim sQry As String
Dim sFirst As Boolean
Dim varBmk As Variant
sFirst = True
For Each varBmk In DataGrid1.SelBookmarks
If sFirst Then
sQry = ("{JOBCOST.Contn} = '" & DataGrid1.Columns(0) & "'"
sFirst = False
Else
sQry = sQry & " or {JOBCOST.Contn} = '" & DataGrid1.Columns(0) & "'"
End If
DataGrid1.SelBookmarks.Remove (0)
Next