Hi Guys,
Im need a little help please.
I written some code which really acts as an append query. The reason i chose to do it through code and not a proper append query is that there are about 20 tables each representing a different country and i would only need to use one of those countries, but i only know which one to use after i have done some other analysis and found that i might be missing a record for that country.
At the moment im getting a Run-time error 424: object required and not sure what is missing. this is line that gives me the error
This is the entire sub:
Im need a little help please.
I written some code which really acts as an append query. The reason i chose to do it through code and not a proper append query is that there are about 20 tables each representing a different country and i would only need to use one of those countries, but i only know which one to use after i have done some other analysis and found that i might be missing a record for that country.
At the moment im getting a Run-time error 424: object required and not sure what is missing. this is line that gives me the error
Code:
Set qCo = Object.CreateQueryDef(zCo)
This is the entire sub:
Code:
Private Sub cmdRunLine_Click()
Dim zCo As String
Dim qCo As QueryDef
Dim zLine As String
Dim zSQL As String
If IsNull(txtCompany) Then
MsgBox "You must enter the company name you intend to update!!"
End If
If IsNull(txtNominal) Then
MsgBox "You need to enter the nominal details before you continue!!"
End If
zCo = "qap" & ("txtCompany") & "SGA1"
zLine = (txtNominal)
Set qCo = Object.CreateQueryDef(zCo)
zSQL = "INSERT INTO TEMP_SGA_CM ( Company, Our_Reference, [Year], Period, Cost_Centre, Reference, Transaction_Date, Description, Job_Code, GL_Code, Department_Code, [Value], Rate, Net_Value, STG, Department, GL_Group, Description_GL, Description_CC )" & _
"SELECT Company, idxOurRef1, thYear, thPeriod, tlCostCentre, thAcCode, tlTransDate, tlDescr, tlJobCode, tlGLCode, tlDepartment, value, xRate, NetValue, Stg, Desc, GL_Group, Description_GL, Description" & _
"FROM qCo" & _
"WHERE qCo.idxOurRef1 = 'zLine'"
CurrentDb.Execute zSQL, DB_FAILONERROR
End Sub