I am currently modifying a form on my access database. More specifically the on click event of a button on the form. The form is based on a Table that only has 3 fiels, ID, GoingToCal, and Location. ID is the autonumber. GoingToCal is a multiselect list box on my form. Location is just where the user is submitting the entry from. The table is simply a way to track what went out at what facility. Before I started messing around I was getting the results that I wanted, which was just a report with all items going out.
The issue that I am having is 2 part. The first error I have doesn't create a runtime error, it simply doens't work. What I am attempting to do is update a recordset of the items selected in the list box. The items are in another table, and I have based my recordset on a query. When I run my code I am expecting first for the specific record to be found(I think works), then update a yes no box to yes. The Yes No field is called StillOut. It is a part of the query. However it doesn't update the Yes No box to Yes, nor does it seem to update any of the boxes. So I am confused as to what I am doing wrong that the field for that record isn't updating.
My Second issue, which I know there can be a few possible ways to work around I just can't make some of them happen. I am using the FindFirst for how I narrow down my recordset to just the one record I want to update. It doesn't seem to like "," with it. I have tried many times when setting the OpenRecordset to the specific record using SQL and a mix of SQL and the Query but no matter how hard I try I can never return any results. It constantly says too few parameters. That is why I am using the FindFirst command.
What I need is advice on how to make the record update the Yes No box and how to specifically change just the records that have been selected in the form and a way to select those records. Here is the code that I am having issue with. As I said the rest worked fine, I just needed an update my supervisor asked for.
The issue that I am having is 2 part. The first error I have doesn't create a runtime error, it simply doens't work. What I am attempting to do is update a recordset of the items selected in the list box. The items are in another table, and I have based my recordset on a query. When I run my code I am expecting first for the specific record to be found(I think works), then update a yes no box to yes. The Yes No field is called StillOut. It is a part of the query. However it doesn't update the Yes No box to Yes, nor does it seem to update any of the boxes. So I am confused as to what I am doing wrong that the field for that record isn't updating.
My Second issue, which I know there can be a few possible ways to work around I just can't make some of them happen. I am using the FindFirst for how I narrow down my recordset to just the one record I want to update. It doesn't seem to like "," with it. I have tried many times when setting the OpenRecordset to the specific record using SQL and a mix of SQL and the Query but no matter how hard I try I can never return any results. It constantly says too few parameters. That is why I am using the FindFirst command.
What I need is advice on how to make the record update the Yes No box and how to specifically change just the records that have been selected in the form and a way to select those records. Here is the code that I am having issue with. As I said the rest worked fine, I just needed an update my supervisor asked for.
Code:
iCount = 0
If Me.GoingToCal.ItemsSelected.Count <> 0 Then
For Each oItem In Me.GoingToCal.ItemsSelected
If iCount = 0 Then
ListItem = ListItem & Me.GoingToCal.ItemData(oItem)
CalEquipment = DLookup("ID", "GoingToCalQuery", "[ID] = " & ListItem)
Set Rs = CurrentDb.OpenRecordset("Select * From GoingToCalQuery")
Rs.FindFirst "ID = " & CalEquipment
With Rs
.Edit
!StillOut = False
.Update
End With
iCount = iCount + 1
Else
ListItem = Me.GoingToCal.ItemData(oItem)
CalEquipment = CalEquipment & ", " & DLookup("ID", "GoingToCalQuery", "[ID] = " & ListItem)
Set Rs = CurrentDb.OpenRecordset("Select * From CalibratedEquipmentListTable")
Rs.FindFirst "ID = " & CalEquipment
With Rs
.Edit
!StillOut = False
.Update
End With
iCount = iCount + 1
End If
Next oItem
End If