JoshuaAnthony
Programmer
The following code works fine because I explicitly reference "[Forms]![Main Page]![Program]"
The PROBLEM is that I actually want to define a make-table query based on my recordSource as the following SQL statement shows:
In this case the "WHERE" condition has already been predefined (including the syntax) based on an existing permanent query.
To combat this and not get "run-time error 3061: Too few arguments. Expected ...", I tried to use some code found at
I added a 'watch' on both 'querydef![Forms!Main!Program]' AND '[Forms]![Main]![Program]'.
They both have the correct value before I try to execute the query.
Unfortunately though, I STILL get "run-time error 3061: Too few arguments. Expected 1"
Can anybody help? I've done loads of searches in google and on this and other forums but nobody seems to have a problem with my specific case!
Thanks,
Joshua
Code:
strSQL = "SELECT * INTO " & strUserTableName & " FROM [Current] WHERE [Program] = '" & [Forms]![Main Page]![Program] & "'"
The PROBLEM is that I actually want to define a make-table query based on my recordSource as the following SQL statement shows:
Code:
strSQL = "SELECT * INTO " & strUserTableName & " FROM [" & Me.RecordSource & "]
In this case the "WHERE" condition has already been predefined (including the syntax) based on an existing permanent query.
To combat this and not get "run-time error 3061: Too few arguments. Expected ...", I tried to use some code found at
Code:
strSQL = "SELECT * INTO " & strUserTableName & " FROM [" & Me.RecordSource & "]
Set querydef = CurrentDb.CreateQueryDef(strUserQueryName, strSQL)
If Me.RecordSource = "Current (Program Search)" Then
querydef![Forms!Main!Program] = [Forms]![Main]![Program]
End If
CurrentDb.Execute querydef.Name
I added a 'watch' on both 'querydef![Forms!Main!Program]' AND '[Forms]![Main]![Program]'.
They both have the correct value before I try to execute the query.
Unfortunately though, I STILL get "run-time error 3061: Too few arguments. Expected 1"
Can anybody help? I've done loads of searches in google and on this and other forums but nobody seems to have a problem with my specific case!
Thanks,
Joshua