Hi Folks,
I have created a query named UniqueNPROV which lists all unique values for the NPROV field from the Claims table. I am trying to write some code, so that once a command button is clicked, a unique table is created from each one of the unique NPROV values and the table has the same name as the NPROV value it uses as the selection criteria. The code is pasted below, and it doesn't work, wondering if someone can tell me what is wrong with it.
Option Compare Database
Private Sub Command0_Click()
Dim SQL As String
Dim SelectCriteria As String
Dim FieldItem As Variant
Set db = CurrentDb
For Each FieldItem In UniqueNPROV
SelectCriteria = ItemData(FieldItem)
SQL = "Select Claims.* INTO " & SelectCriteria & "From Claims where n_prov = " & SelectCriteria & ""
Next FieldItem
End Sub
Any help would be greatly appreciated.
Thank you very much,
Joe
I have created a query named UniqueNPROV which lists all unique values for the NPROV field from the Claims table. I am trying to write some code, so that once a command button is clicked, a unique table is created from each one of the unique NPROV values and the table has the same name as the NPROV value it uses as the selection criteria. The code is pasted below, and it doesn't work, wondering if someone can tell me what is wrong with it.
Option Compare Database
Private Sub Command0_Click()
Dim SQL As String
Dim SelectCriteria As String
Dim FieldItem As Variant
Set db = CurrentDb
For Each FieldItem In UniqueNPROV
SelectCriteria = ItemData(FieldItem)
SQL = "Select Claims.* INTO " & SelectCriteria & "From Claims where n_prov = " & SelectCriteria & ""
Next FieldItem
End Sub
Any help would be greatly appreciated.
Thank you very much,
Joe