I am trying to have a Textbox auto populate based on a query but I get a error "DoCmd.RunSQL must have argument consisting of a SQL statement"... but there IS a SQL statement. What am I doing wrong? Here's code. The Debug stops at "DoCmd.RunSQL SQLB"
Private Sub cmdCreateADdistinct_Click()
Dim strADTableName As String
Dim strSQL As String
Dim strSQLB As String
strADTableName = Forms![AD_Processor].[txtNewADTableName]
strSQL = "SELECT DISTINCT [" & strADTableName & "].DataSource, [" & strADTableName & "].AccountName, [" & strADTableName & "].LastName, [" & strADTableName & "].FirstName, [" & strADTableName & "].EEID, [" & strADTableName & "].[SYS/GenericAcct], [" & strADTableName & "].Notes, [" & strADTableName & "].Status, [" & strADTableName & "].Created INTO " & strADTableName & "DistinctAccts FROM " & strADTableName & ";"
strSQLB = "SELECT y_LatestExtracts.TableName FROM y_LatestExtracts WHERE (((Right(([Forms]![AD_Processor]![txtNewADdistinct]),31))=([y_LatestExtracts].[TrimmedTableName])));"
DoCmd.RunSQL strSQL
Me!txtNewADdistinct = "" & strADTableName & "DistinctAccts"
DoCmd.RunSQL strSQLB
Me!txtOldADdistinct = "" & strSQLB & ""
End Sub
Private Sub cmdCreateADdistinct_Click()
Dim strADTableName As String
Dim strSQL As String
Dim strSQLB As String
strADTableName = Forms![AD_Processor].[txtNewADTableName]
strSQL = "SELECT DISTINCT [" & strADTableName & "].DataSource, [" & strADTableName & "].AccountName, [" & strADTableName & "].LastName, [" & strADTableName & "].FirstName, [" & strADTableName & "].EEID, [" & strADTableName & "].[SYS/GenericAcct], [" & strADTableName & "].Notes, [" & strADTableName & "].Status, [" & strADTableName & "].Created INTO " & strADTableName & "DistinctAccts FROM " & strADTableName & ";"
strSQLB = "SELECT y_LatestExtracts.TableName FROM y_LatestExtracts WHERE (((Right(([Forms]![AD_Processor]![txtNewADdistinct]),31))=([y_LatestExtracts].[TrimmedTableName])));"
DoCmd.RunSQL strSQL
Me!txtNewADdistinct = "" & strADTableName & "DistinctAccts"
DoCmd.RunSQL strSQLB
Me!txtOldADdistinct = "" & strSQLB & ""
End Sub