Hello,
I am trying to use this form:
[IMGnothumb]http://i.imgur.com/06RWh0Y.jpg[/IMGnothumb]
to select a program type and generate a random list to audit. This part is working correctly. But I would like to use a variable either a number or a percent to input as the TOP x PERCENT|NUMBER in my SQL statement from the form.
My code looks like this:
When I change the hard coding to either a number or percent this works, but I want other people who are unfamiliar with VBA to be able to generate an audit report too.
Any help would be greatly appreciated!
Thanks.
I am trying to use this form:
[IMGnothumb]http://i.imgur.com/06RWh0Y.jpg[/IMGnothumb]
to select a program type and generate a random list to audit. This part is working correctly. But I would like to use a variable either a number or a percent to input as the TOP x PERCENT|NUMBER in my SQL statement from the form.
My code looks like this:
Code:
strTableName = "tblAuditSample_" & Format(Date, "ddmmmyyyy")
strSQL = "SELECT TOP 10 PERCENT tblTemp.SHC_No, tblTemp.Project_Name, tblTemp.Program_Type, tblTemp.PMC " & _
"INTO " & strTableName & " " & _
"FROM tblTemp " & _
"ORDER BY tblTemp.RandomNumber;"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
Any help would be greatly appreciated!
Thanks.
Comment