Make Table as oppossed to Making Query

joe789

Registered User.
Local time
Today, 10:26
Joined
Mar 22, 2001
Messages
154
Hi Folks,

I have a snipet of code that I am working with, unfortunetly; I don't know VB very well and was wondering how to create a table with this code as oppossed to making and opening a query. The code works fine thus far.

.....

SQL = " SELECT * " & _
" FROM dbo_v_claim_ap_pmtD " & _
" WHERE (clmstat = 'a' or clmstat = 'p') and (procstat = 'p' or procstat = 'f') and (fiscal_year = '2002' or fiscal_year = '2003') and company = 'lucam' and " & sCriteria & sCriteria2 & sCriteria3

Set db = CurrentDb

On Error Resume Next
db.QueryDefs.Delete "qryDataType"

On Error GoTo 0

Set qDef = db.CreateQueryDef("qryDataType", SQL)

DoCmd.OpenQuery "qryDataType"

End Sub

...

I would appreciate any help I can receive.

Thank you very much,

Joe
 
Presume that you want to change this to a make table query. If so then here is the code:

SQL = " SELECT * INTO MyTableName" & _
" FROM dbo_v_claim_ap_pmtD " & _
" WHERE (clmstat = 'a' or clmstat = 'p') and (procstat = 'p' or procstat = 'f') and (fiscal_year = '2002' or fiscal_year = '2003') and company = 'lucam' and " & sCriteria & sCriteria2 & sCriteria3

Set db = CurrentDb

On Error Resume Next
db.QueryDefs.Delete "qryDataType"

On Error GoTo 0

Set qDef = db.CreateQueryDef("qryDataType", SQL)

DoCmd.OpenQuery "qryDataType"

End Sub
 
Thanks Harry, it worked perfectly.
 

Users who are viewing this thread

Back
Top Bottom