In Access, Using VBA Only, I am trying to write A Make-Table Query from a table named CompSales INTO a table named Temp using conditions from a form, and then get a count of records. If I write the query in design view it works, but coding in VBA it does not return a record count or update my table called Temp. Suggestions?
'------------------
Option Explicit
Dim X As Integer
Dim FirstPull_Cnt As Integer
Dim strSQL As String
Private Sub FirstPull()
strSQL = "SELECT CompSales.Stat, CompSales.Property, CompSales.[Nbh Code] INTO Temp" & _
"FROM CompSales" & _
"HAVING (((CompSales.Property) Not Like [Forms]![frmSubject]![Property]) AND" & _
"(CompSales.[Stat]) Is Not Null) AND" & _
"((CompSales.[Nbh]) Like [Forms]![frmSubject]![Nbh])"
X = DCount("[Property]", "Temp")
FirstPull_Cnt = X
End Sub
'------------------
Option Explicit
Dim X As Integer
Dim FirstPull_Cnt As Integer
Dim strSQL As String
Private Sub FirstPull()
strSQL = "SELECT CompSales.Stat, CompSales.Property, CompSales.[Nbh Code] INTO Temp" & _
"FROM CompSales" & _
"HAVING (((CompSales.Property) Not Like [Forms]![frmSubject]![Property]) AND" & _
"(CompSales.[Stat]) Is Not Null) AND" & _
"((CompSales.[Nbh]) Like [Forms]![frmSubject]![Nbh])"
X = DCount("[Property]", "Temp")
FirstPull_Cnt = X
End Sub