Unanswered: Run an update query on items in a list box.
This is probably a simple matter but I have searched hi and low and can't find any help on this. I have a list box of table names and I would like to run an update query or an append query on each one selected. Nothing fancy. I don't need to loop through the entries just run the updates one at a time.
Private Sub Command20_Click()
DoCmd.RunSQL "UPDATE [list0] SET [list0] tblWWWW1.[date] = [enter a date]"
This doesn't work. But a hardcoded table name does. This seems like something that should be very common but I can't find any help anywhere. Basically I want to run the same query on about 20 different tables. prompting for the date.
I know that sql won't evaluate something like list0. Anyway to force it to. Any suggestions will be appreciated.
The question implies a design issue, so I'd wonder what the different tables represent. In any case, first you want to search here on "multiselect" to get the code to loop through the items selected in the listbox. Then your code would have to be tweaked a little:
DoCmd.RunSQL "UPDATE " & ListboxVariable & " SET tblWWWW1.[date] = [enter a date]"