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!

Column Property of a Combo Box

Status
Not open for further replies.

alightchaser

Programmer
Jun 27, 2003
2
US
I'm new at this so be patient with me...

I need to update a M2M table (contractors assigned to projects) with contractor ids from the contractor table and project id from the project table. The contractors and projects are selected from two combo boxes cmbx_contractor_id_name & cmbx_project_id_name on the form frm_assign_contractor_project.

I get a runtime error 450 - Wrong number of input arguements or invalid property assignment on the
contractorid = [Forms]!...statement in the following code..

Private Sub save_cont_proj_Click()
Dim contractorid As Integer
Dim projectid As Integer
Dim thisdb As Database
Dim strSQLQuery As String
Set thisdb = CurrentDb()

contractorid = [Forms]![frm_assign_contractor_project]![cmbx_contractor_id_name].[Column](0)
projectid = [Forms]![frm_assign_contractor_project]![cmbx_project_id_name].[Column](0)

strSQLQuery = "INSERT INTO tbl_contractor_project (contractor_id , project_id) VALUES (" & contractorid & "," & projectid & ");"

thisdb.Execute strSQLQuery

End Sub

Alightchaser

 
Alightchaser: To be 100% sure you will need to clean up your syntax and formats.


CHANGE:
contractorid = [Forms]![frm_assign_contractor_project]![cmbx_contractor_id_name].[Column](0)
projectid = [Forms]![frm_assign_contractor_project]![cmbx_project_id_name].[Column](0)
TO:
contractorid = Me.cmbx_contractor_id_name.Column(0)
projectid = Me.cmbx_project_id_name.Column(0)
(I may be telling you what you already know but to be sure: In the form properties, set Has Module to Yes, keep the relevant code in the form module and keep it simple. )

CHANGE:
strSQLQuery = "INSERT INTO tbl_contractor_project (contractor_id , project_id) VALUES (" & contractorid & "," & projectid & ");"
TO:
strSQLQuery = "INSERT INTO tbl_contractor_project (contractor_id , project_id) VALUES ('" & contractorid & "','" & projectid & "');"
(see the extra irk outside each birk)

Check that the formats of the source table fields is the same as the destination table fields (eg contractorid and projectid are integers); obvious, but we all forget at times.
regards,
John
 
John,
I incorporated your changes and it worked great!! Thank you so much for taking the time to help me out...

Alightchaser
 
Anytime mate. You will need to learn about the requirements for ", '", "" and """ quotation marks. I think your major problem was using " instead of '" around a control reference.
regards,
John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top