The code below is used in MS Access.
The listbox mentioned below is drawn from a table.
The command button is supposed to update another column in that table based on the items listed in the listbox.
To illustrate this, it's used for inspections. Other functions in the program generate a random list of organizations from the GRANDE TABLE to inspect and make a new SMALL table based on the random list (named table_20110120 or table_whateverthedateis).
There is a search box that you can type in the the date, such as 20110120, and it will populate the listbox with table_whateveryoursearchedfor.
The third part, which is not working, is once the company is inspected, users are supposed to be able to use the search to bring up the companies from that date, and have the code below update the date of inspection on the GRANDE TABLE.
But the code generates an error that requires debugging, saying that lstitem is null. I'm not exactly sure why this is. Any input would greatly be appreciated.
I've attached a copy of the application so you can see what I mean.
The listbox mentioned below is drawn from a table.
The command button is supposed to update another column in that table based on the items listed in the listbox.
To illustrate this, it's used for inspections. Other functions in the program generate a random list of organizations from the GRANDE TABLE to inspect and make a new SMALL table based on the random list (named table_20110120 or table_whateverthedateis).
There is a search box that you can type in the the date, such as 20110120, and it will populate the listbox with table_whateveryoursearchedfor.
The third part, which is not working, is once the company is inspected, users are supposed to be able to use the search to bring up the companies from that date, and have the code below update the date of inspection on the GRANDE TABLE.
Code:
Private Sub Command31_Click()
Dim lstitem As String
For i = 1 To list.ListCount
lstitem = list.Column(i)
date3 = Format(Date, "yyyymmdd")
strSQL3 = "UPDATE ContractorData SET LastInspection = " & date3 & " WHERE Name = " & lstitem & ";"
DoCmd.RunSQL strSQL3
Next i
End Sub
But the code generates an error that requires debugging, saying that lstitem is null. I'm not exactly sure why this is. Any input would greatly be appreciated.
I've attached a copy of the application so you can see what I mean.
Attachments
Last edited: