Hi Everyone! I have a make-table query with a parameter. I have a function which does the following:
1) ask for a new table name
2) start running the SQL query
3) the SQL query asks for a parameter
4) the new table is created with the new query data.
Here is the code:
Function CreateTable()
Dim NewTableName As String
NewTableName = InputBox("Please select new table name")
If Len(Trim(NewTableName)) <> 0 Then
DoCmd.RunSQL "PARAMETERS KockKod Text ( 255 ); SELECT [Kockazatok-proba].RiskID, [Kockazatok-proba].[Risk name], Nevek.Vezetéknév, Nevek.Keresztnév, Nevek.[Harmadik név], Nevek.[E-mail cím] INTO " & NewTableName & " FROM [Kockazatok-proba] INNER JOIN Nevek ON [Kockazatok-proba].Nevek.Value = Nevek.Vezetéknév WHERE ((([Kockazatok-proba].RiskID)=[KockKod]))"
End If
End Function
My problem is that the table name is the parameter, so is it possible to make the code to make a new table with the name of parameter, without prompting me for a new table name at the beginning.
Thank you in advance!
1) ask for a new table name
2) start running the SQL query
3) the SQL query asks for a parameter
4) the new table is created with the new query data.
Here is the code:
Function CreateTable()
Dim NewTableName As String
NewTableName = InputBox("Please select new table name")
If Len(Trim(NewTableName)) <> 0 Then
DoCmd.RunSQL "PARAMETERS KockKod Text ( 255 ); SELECT [Kockazatok-proba].RiskID, [Kockazatok-proba].[Risk name], Nevek.Vezetéknév, Nevek.Keresztnév, Nevek.[Harmadik név], Nevek.[E-mail cím] INTO " & NewTableName & " FROM [Kockazatok-proba] INNER JOIN Nevek ON [Kockazatok-proba].Nevek.Value = Nevek.Vezetéknév WHERE ((([Kockazatok-proba].RiskID)=[KockKod]))"
End If
End Function
My problem is that the table name is the parameter, so is it possible to make the code to make a new table with the name of parameter, without prompting me for a new table name at the beginning.
Thank you in advance!
Last edited: