Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating a Make-Table Query in VBA

Status
Not open for further replies.

cwadams

Technical User
Apr 9, 2007
26
US
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
 
I see that you have already got answers to this same question in 2 other forums on this site. Please read faq222-2244 to see how the forum works - it gives guidance on selecting the right forum, not cross-posting and acknowledging helpful answers.

___________________________________________________________
If you want the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
Steam Engine Prints
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top