Hi Guys, I'm trying to make a pass through query which connects to a postgresql server. However, When I try running it by clicking on a button, I get:
"Run-time error '3306':
Query must have at least one destination field
I have tried debugging it and all the values in the parameters are being recieved from the forms. and the first parameter is being highlighted. In the occasion I did try running the query, all the fields were null (expected) apart from PAdviser_ID, which was 18.
I've attached my code, if anyone wants to have a look.
If you want any more information, or to ask any questions then feel free to ask.
Cheers,
Ben
"Run-time error '3306':
Query must have at least one destination field
I have tried debugging it and all the values in the parameters are being recieved from the forms. and the first parameter is being highlighted. In the occasion I did try running the query, all the fields were null (expected) apart from PAdviser_ID, which was 18.
I've attached my code, if anyone wants to have a look.
Code:
Dim MyDb As DAO.Database, MyQry As QueryDef, MyRS As DAO.Recordset
Set MyDb = CurrentDb()
Set MyQry = MyDb.CreateQueryDef("")
MyQry.Parameters("PAdviser_ID") = [Forms]![frm_MainMenu]![CurrentReport]
MyQry.Parameters("PProvider_ID") = [Forms]![frm_ReportSelect]![Provider_ID]
MyQry.Parameters("PIntroducer_ID") = [Forms]![frm_ReportSelect]![Introducer_ID]
MyQry.Parameters("PPlanGroup_ID") = [Forms]![frm_ReportSelect]![PlanGroup_ID]
MyQry.Parameters("PPlanType_ID") = [Forms]![frm_ReportSelect]![PlanType_ID]
MyQry.Parameters("PDateSpecific_Start") = [Forms]![frm_ReportSelect]![DateSpecific_Start]
MyQry.Parameters("PDateSpecific_End") = [Forms]![frm_ReportSelect]![DateSpecific_End]
MyQry.Parameters("PDate_Start") = [Forms]![frm_ReportSelect]![Child26]![DateList_Start]
MyQry.Parameters("PDate_End") = [Forms]![frm_ReportSelect]![Child24]![DateList_End]
MyQry.Connect = "ODBC;DRIVER={PostgreSQL};DATABASE=testing;SERVER=10.0.0.2;PORT=5432;Uid=xxxxxxxxxx;Pwd=xxxxxxxx;"
MyQry.ReturnsRecords = True
If Forms![frm_MainMenu].[CurrentReport] = 18 Then
MyQry.SQL = "select * from reports as (& PAdviser_ID & ','& PProvider_ID &','& PIntroducer_ID & ',' & PPlanGroup_ID & ',' & PPlanType & ',' & PDateSpecific_Start & ',' & PDateSpecific_End & ',' & PDate_Start & ',' & PDate_End) & ' as employee_first_name varchar,employee_last_name varchar,date_issued date,client_first_name varchar,client_middle_names varchar,client_surname varchar,tblplantypes.plantype_group varchar,plangroups.plangroups_group varchar,tblproviders.provider_company varchar,policy_number varchar,sum_assured numeric,benefit varchar, premium numeric,brokerage numeric, comments text);'"
ElseIf Forms![frm_MainMenu].[CurrentReport] = 13 Then
MyQry.SQL = "select * from reports([Forms]![frm_MainMenu]![CurrentReport],[Forms]![frm_ReportSelect]![Adviser_ID],[Forms]![frm_ReportSelect]![Provider_ID],[Forms]![frm_ReportSelect]![Introducer_ID],[Forms]![frm_ReportSelect]![PlanGroup_ID],[Forms]![frm_ReportSelect]![PlanType_ID],[Forms]![frm_ReportSelect]![DateSpecific_Start],[Forms]![frm_ReportSelect]![DateSpecific_End],[Forms]![frm_ReportSelect]![Child24],[Forms]![frm_ReportSelect]![Child26])"
ElseIf Forms![frm_MainMenu].[CurrentReport] = 23 Then
MyQry.SQL = "select * from reports([Forms]![frm_MainMenu]![CurrentReport],[Forms]![frm_ReportSelect]![Adviser_ID],[Forms]![frm_ReportSelect]![Provider_ID],[Forms]![frm_ReportSelect]![Introducer_ID],[Forms]![frm_ReportSelect]![PlanGroup_ID],[Forms]![frm_ReportSelect]![PlanType_ID],[Forms]![frm_ReportSelect]![DateSpecific_Start],[Forms]![frm_ReportSelect]![DateSpecific_End],[Forms]![frm_ReportSelect]![Child24],[Forms]![frm_ReportSelect]![Child26])"
ElseIf Forms![frm_MainMenu].[CurrentReport] = 25 Then
MyQry.SQL = "select * from reports([Forms]![frm_MainMenu]![CurrentReport],[Forms]![frm_ReportSelect]![Adviser_ID],[Forms]![frm_ReportSelect]![Provider_ID],[Forms]![frm_ReportSelect]![Introducer_ID],[Forms]![frm_ReportSelect]![PlanGroup_ID],[Forms]![frm_ReportSelect]![PlanType_ID],[Forms]![frm_ReportSelect]![DateSpecific_Start],[Forms]![frm_ReportSelect]![DateSpecific_End],[Forms]![frm_ReportSelect]![Child24],[Forms]![frm_ReportSelect]![Child26])"
End If
MyQry.Execute (MyQry.SQL)
Set MyRS = MyQry.OpenRecordset()
MyRS.MoveFirst
Debug.Print MyRS!attribute_id, MyRS!attribute_name, _
MyRS!attribute_value
MyQry.Close
MyRS.Close
MyDb.Close
If you want any more information, or to ask any questions then feel free to ask.
Cheers,
Ben
Last edited: